struts1标签-<html:radio> 使用注意事项

struts1标签-<html:radio> 使用注意事项

1、默认选中效果

  在后台XxxForm中写入如下代码,可保证默认选中效果实现:

@Override
public void reset(ActionMapping mapping, HttpServletRequest request) {
ve.setBuytaxisf("是");//是否免税交纳属性默认选中效果
super.reset(mapping, request);
}

  jsp代码:

<html:radio property="ve.buytaxisf" value="是"></html:radio>
<html:radio property="ve.buytaxisf" value="否"></html:radio>

 

  页面效果:

  好处:1、不用设置默认值;2、页面选中效果自动实现。

  缺点:在action中接收并使用(XxxForm)xxxForm进行查询时,需将设置默认值的属性set为null,否则在查询条件(xxxForm对象)中包含默认值

2、禁用效果

<html:radio property="ve.buytaxisf" value="" style="display: none"></html:radio>
<html:radio property="ve.buytaxisf" value="是" disabled="true"></html:radio>
<html:radio property="ve.buytaxisf" value="否" disabled="true"></html:radio>

 

  页面效果:

  注:测试发现,当把所有radio都设置成disabled,总会把第一个默认为可选,所以可以采用如上方法实现禁用效果

posted @ 2014-12-23 17:51  OwnSail  阅读(1702)  评论(0编辑  收藏  举报