【发布时间】:2013-02-15 09:29:24
【问题描述】:
我的程序出了什么问题?我认为一切都很好。我的changeKeyValue 方法获取选定的值'REFERENCE'并将true 布尔值设置为showReference。
但是,如果我在p:ajax 中使用update="targetPanel",我的页面将无法呈现h:panelGroup。
当我使用update="entryForm" 时,它可以渲染h:panelGroup。
我错过了什么?
mypage.xhtml
<h:form id="entryForm">
<p:selectOneMenu value="#{MyBean.keyFactorValue}" required="true" style="width:257px;" id="keyFactorValue">
<f:selectItems value="#{MyBean.selectItemList}" var="type" itemLabel="#{type.label}" itemValue="#{type}"/>
<p:ajax listener="#{MyBean.changeKeyValue}" update="targetPanel" event="change"/>
</p:selectOneMenu>
<h:panelGroup id="targetPanel" rendered="#{MyBean.showReference}">
.......
</h:panelGroup>
</h:form>
KeyFactorValue.java
public enum KeyFactorValue {
REFERENCE("Reference"), FORM_TO("From-To"), FIXED("Fixed");
private String label;
private KeyFactorValue(String label) {
this.label = label;
}
public String getLabel() {
return label;
}
}
MyBean.java
@Scope(ScopeType.CONVERSATION)
@Name("MyBean")
public class MyBean {
private boolean showReference;
public boolean isShowReference() {
return showReference;
}
public KeyFactorValue[] getSelectItemList() {
return KeyFactorValue.values();
}
public void changeKeyValue(AjaxBehaviorEvent e) {
KeyFactorValue type = keyFactor.getKeyFactorValue();
System.out.println("Selected KeyFactorValue : " + type);
switch(type) {
case REFERENCE :{
showReference = true;
break;
}
default :{
showReference = false;
break;
}
}
}
}
【问题讨论】:
标签: java jsf primefaces