좋아, 며칠 동안 이걸로 꼼짝 못 했어. JSF ValueChangeEvent : 이전 SelectOneMenu에서 선택한 항목을 기반으로 한 SelectOneMenu의 옵션을 변경하려면 어떻게해야합니까?
내가 selectOneMenu<h:selectOneMenu id="selectFamily" valueChangeListener="#{menuBean.changeFamily}" onclick="submit()" immediate="true" > <f:selectItems id="familyNames" value="#{menuBean.familyNames}" /> </h:selectOneMenu>
말해봐 그리고 나는이 이전 selectOneMenu에 을 선택한 옵션에 따라 다른 selectOneMenu의 옵션을 변경하고 싶습니다.
<h:selectOneMenu id="selectFunction" immediate="true">
<f:selectItems id="functions" value="#{menuBean.functions}" />
</h:selectOneMenu>
어떻게 내가 이렇게? 주위를 읽고, 내가 그것을 수행하는 방법의 몇 가지 아이디어를 가지고,하지만 난 바로 그것을 얻을 수없는 것. 죄송합니다. 누군가가 나를 인도 할 수 있기를 바란다면 여기 콩 클래스를 털어 놓을 것입니다.공용 클래스 MenuBean {
/** Creates a new instance of MenuBean */ public MenuBean() { } private SelectItem[] familyNames = { new SelectItem((Integer) 1,"Operations"), new SelectItem((Integer) 2, "Special"), new SelectItem((Integer) 3, "Support")}; public SelectItem[] getFamilyNames() { return familyNames; } private SelectItem[] functions = {new SelectItem("Select Function")}; private SelectItem[] operationsFunctions = { new SelectItem("Air/Ocean Freight"), new SelectItem("Customs"), new SelectItem("Land Transport"), new SelectItem("Logistics/SCM"), new SelectItem("Rail Transport"), new SelectItem("Special") }; private SelectItem[] specialFunctions = { new SelectItem("General Management"), new SelectItem("Quality & Processes") }; private SelectItem[] supportFunctions = { new SelectItem("Finance/Controlling"), new SelectItem("Human Resources"), new SelectItem("ICT"), new SelectItem("Legal Affairs"), new SelectItem("Marketing/Public Relations"), new SelectItem("Procurement"), }; public SelectItem[] getFunctions(int n) { if (n==1) { functions = operationsFunctions; } else if (n==2) { functions = specialFunctions; } else if (n==3) { functions = supportFunctions; } return functions; } public void setFunctions(SelectItem[] function) { this.functions = function; } public void changeFamily(ValueChangeEvent event) { FacesContext context = FacesContext.getCurrentInstance(); int value = (Integer) event.getNewValue(); setFunctions(getFunctions(value)); context.renderResponse(); }}
당신이 JSF1.2 또는 2를 사용하고 있습니까? – Dejell
JSF 2를 사용하고 있습니다. –