自己动手写struts实现下拉框多级联动

约束: 必须以id作为下拉框的value, name为下落框的label;

使用方法: 以三级资料类别为例。

jsp页面:
		<tr class="whitebg">
<td width="15%" height="20" class="gray">文档类型<span class="redStar">*</span></td>
<td>
<html:select property="docTypeL1Id"
onchange="setProperty('docTypeL2Id','');;setProperty('docTypeL3Id','');;refreshPage(this);">
<option value=""><bean:message key="label.pleaseSelect" bundle="common" /></option>
<html:optionsCollection property="docTypeL1Options" />
</html:select>
<html:select property="docTypeL2Id"
onchange="setProperty('docTypeL3Id','');;refreshPage(this);">
<option value=""><bean:message key="label.pleaseSelect"
bundle="common" /></option>
<xxx:dynamicOptions parentProperty="docTypeL1Id"
sqlModule="module_doc" sqlName="sql_doc_options_doctypel2" />
</html:select>
<html:select property="docTypeL3Id"
onchange="refreshPage(this);">
<option value=""><bean:message key="label.pleaseSelect"
bundle="common" /></option>
<xxx:dynamicOptions parentProperty="docTypeL2Id"
sqlModule="module_doc" sqlName="sql_doc_options_doctypel3" />
</html:select></td>
</tr>



formBean:
	private String docTypeL1Id;
/**
* 一级资料类别下拉框选项列表
*/
private ArrayList docTypeL1Options = new ArrayList();;
private String docTypeL2Id;
private String docTypeL3Id;


action:
	/**
* 跳转到“创建资料步骤一”页面。
*
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward showCreateDocStep1(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response);
throws Exception {
DocForm docForm = (DocForm); form;
DocDelegate docDelegate = new DocDelegate();;

//设置当前左菜单栏的焦点
BarFocus.setFocus(request, BarFocus.PW_CREATE_DOC);;
//进入页面之前需要把第一级资料类别下拉框的数据准备好。
DocViewHelper.prepareViewHelpData(docForm);;
return mapping.findForward("createDocStep1");;
}

//刷新页面执行的方法, 也可调用showCreateDocStep1
public ActionForward refreshPage(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response);
throws Exception {
DocViewHelper.prepareViewHelpData((DocForm); form);;
return (mapping.findForward("createDocStep1"););;
}



SQL.xml:

<!-- 文档模块 SQL语句 -->
   <module_doc
sql_doc_options_doctypel2="SELECT * FROM T_BASE_DOC_TYPE WHERE DOC_TYPE_LEVEL='2' AND PARENT_ID=? ORDER BY NAME ASC"
sql_doc_options_doctypel3="SELECT * FROM T_BASE_DOC_TYPE WHERE DOC_TYPE_LEVEL='3' AND PARENT_ID=? ORDER BY NAME ASC"
/>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值