JSF: 双联菜单(双级联动菜单)实例,源代码
刚开始接触JSF的时候到处找双联菜单,后来自己写了个,是链接数据库的。 不过这里作为一个演示把数据库部分删除了,可直接运用
希望可以供初学JSF的朋友使用。
select.jsp
<%@page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ page language="java"%>
<html>
<f:view>
<head>
<title>Search_Advance</title>
</head>
<body>
<h:form>
<h:selectOneMenu value="#{selectItem.selectedOne}"
onchange="this.form.submit();"
style="position:absolute; left:95; top: 90; width:100; height:35"
valueChangeListener="#{selectItem.selectedOneChange}">
<f:selectItems value="#{selectItem.LMList}" />
</h:selectOneMenu>
<h:selectOneMenu value="#{selectItem.selectedTwo}"
style="position:absolute; left:95; top: 135; width:100; height:35"
onchange="this.form.submit();"
valueChangeListener="#{selectItem.selectedTwoChange}"
immediate="true">
<f:selectItems value="#{selectItem.currentMCList}" />
</h:selectOneMenu>
<h:commandButton type="submit" value="OK"
style="position:absolute; left: 140; top: 220;"
action="#{selectItem.saveCondition}"/>
</h:form>
</body>
</f:view>
</html>
MySelect.java
package mypackage;
import java.util.LinkedList;
import java.util.List;
import java.util.Vector;
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.SelectItem;
public class MySelect {
public List<SelectItem> LMList = new LinkedList<SelectItem>();;
public Vector<List<