我的页面中有这棵树:
[]
在我的bean中,方法“cmdSaveSinglemyObjectItem”执行此操作:
<h:form id="form" >
<h:panelGrid columns="4" id="panel">
<p:tree id="tree1"
value="#{mybean.myObject}"
var="myObject"
selectionMode="single"
selection="#{mybean.selectedNode}"
draggable="true"
droppable="true"
dragdropScope="myObjectTest">
<p:ajax event="dragdrop"
listener="#{mybean.onDragDrop}"
update=":form:msgs" />
<p:treeNode id="treeNode1">
<div>
<h:outputText value="#{myObject.label}" />
</div>
<div> </div>
<p:commandLink update=":formDialogmyObject:myObjectPanel" oncomplete="PF('documentDialog').show()" title="View">
<f:setPropertyActionListener value="#{myObject}" target="#{mybean.selectedmyObject}" />
</p:commandLink>
</p:treeNode>
</p:tree>
<p:tree id="tree2"
value="#{mybean.myObjectAvailable}"
var="myObjectAvailable"
selectionMode="single"
selection="#{mybean.selectedNode}"
draggable="true"
droppable="true"
dragdropScope="myObjectTest"
>
<p:ajax event="dragdrop"
listener="#{mybean.onDragDropDelete}"
update=":form:msgs" process="" />
<p:treeNode>
<h:outputText value="#{myObjectAvailable.label}" />
</p:treeNode>
</p:tree>
</h:panelGrid>
<br />
</h:form>
<p:dialog
id="dialogmyObject"
showEffect="clip"
hideEffect="clip"
widgetVar="documentDialog"
modal="true"
resizable="false"
appendTo="@(body)"
binding="#{mybean.dialog}"
>
<h:form id="formDialogmyObject" >
<p:outputPanel id="myObjectPanel" >
<p:panelGrid columns="2" columnClasses="label,value" rendered="#{not empty mybean.selectedmyObject}">
<h:outputLabel for="idmyObject" value="ID myObject" />
<h:outputText id="idmyObject" value="#{mybean.selectedmyObject.idmyObject}" />
</p:panelGrid>
<br />
<p:commandButton
id="cmdSaveSinglemyObjectItem"
action="#{mybean.onSavemyObjectItem()}"
value="Save"
update=":form:tree1:treeNode1"
/>
</p:outputPanel>
</h:form>
Bean已正确更新,但树组件(id = tree1)未更新。查看旧值,但如果我刷新页面我查看数据更新...
答案 0 :(得分:0)
您应该更新整个树而不仅仅是它的特定子元素。
update=":form:tree1"
而不是update=":form:tree1:treeNode1"