日期:2014-05-16  浏览次数:20430 次

(1)用struts实现jsp页面中的下拉框、单选框
(1)用struts实现jsp页面中的下拉框、单选框
      <primary-key>
            <column>
                <name>admin_name</name>
                <sql-name>ADMIN_NAME</sql-name>
                <title>admin_name</title>
                <type>string</type>
                <validation>
                    <required>true</required>
                    <max-length>32</max-length>
                </validation>
<value>
                    <widget>select</widget> <choice>
   <code>code</code>
              <display>display</display>
</choice>
<choice>
           <code>code2</code>
          <display>display2</display>
</choice>
                </value>
            </column>
        </primary-key>
生成的为下拉框,效果为:
<html:select property="admin_status">
<html:option value="0">
<bean:message key="Tab_ch_admin.admin_status.0"/>
</html:option>
<html:option value="1">
<bean:message key="Tab_ch_admin.admin_status.1"/>
</html:option>
</html:select>
如果把粉红色的widget值改成"radio"则可以实现单选框,效果为
<html:radio property="admin_status" value="0"/>
<bean:message key="Tab_ch_admin.admin_status.0"/> 
<html:radio property="admin_status" value="1"/>
<bean:message key="Tab_ch_admin.admin_status.1"/> 
(2)相应的,需要在form文件中增加以下语句 
private String admin_nameDisplay = ""; // Display Helper
(3)在资源文件中配置
Tab_ch_admin.admin_name.code=display
Tab_ch_admin.admin_name.code2=display2
(4)在jsp页面显示为
  <logic:equal name="tab_ch_adminForm" property="strutsAction" scope="request" value="1">
    <tr bgcolor="">

<td style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; BORDER-LEFT: 1px solid; BORDER-BOTTOM: 1px solid" class="FieldCaptionTD" width="20%"><bean:message key="Tab_ch_admin.admin_name"/></td><td style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; BORDER-LEFT: 1px solid; BORDER-BOTTOM: 1px solid" class="DataTD" width="*">
<html:radio property="admin_name" value="code"/><bean:message key="Tab_ch_admin.admin_name.code"/> 
<html:radio property="admin_name" va