我在bean中有以下方法:
public void methodBean(String key){
MyObject object = new MyObject();
System.out.println("parent key: " + key);
if (key != null && !key.equals("")) {
object = MyClient.getInfo(key);
myMapChild = MyDomain.dataToModel(object);
}else{
myMapChild = new HashMap<String, String>();
}
}
点击父p:commandbutton:(xhtml)
<p:tab id="step2" title="TEST STEP 2">
<p:panel id="panelCategory">
<h:panelGrid id="testStep2" columns="1">
<h:panelGrid columns="1" columnClasses="label" >
<p:panelGrid>
<f:facet name="header">
<p:row>
<p:column colspan="6">Title</p:column>
</p:row>
</f:facet>
<p:row>
<c:forEach items="#{myBean.myMapParent}" var="entry">
<p:commandButton value="#{entry.value}" action="#{myBean.methodBean(entry.key)}" update="catalogChildList"
/>
</c:forEach>
</p:row>
</p:panelGrid>
<p:panelGrid id="catalogChildList">
<p:row>
<c:forEach items="#{myBean.myMapChild}" var="entry" >
<p:column>
<p:commandButton value="#{entry.value}"/>
</c:forEach>
</p:row>
</p:panelGrid>
</h:panelGrid>
</h:panelGrid>
</p:panel>
必须更新列表并显示相应的按钮,问题是第一次点击不会更新子按钮,但第二次点击会更新内容。
谢谢大家的答案