How to update panel from datatable [duplicate]

巧了我就是萌 提交于 2019-12-31 04:24:49

问题


Commandbutton with id("myButtonId2") works fine. I mean it updates "myOutputPanel" but commandbutton which is inside datatable doesn't update outputPanel. Is there a specific update style for datatables?

<h:form id="myForm" prependId="false">
  <p:panel id="myPanel">
     <p:dataTable id="myDatatable">
        <p:column style="width:4%">  
          <p:commandButton id="myButtonId" update="myOutputPanel"/>
        </p:column>
     </p:dataTable>
     <p:commandButton id="myButtonId2" update="myOutputPanel"/>
    </p:panel>

 <p:outputPanel id="myOutputPanel">
  //some stuff
 </p:outputPanel>

回答1:


This is because with process and update they work much the same way as the f:ajax component attributes execute and render do. One can only reference the id of a component directly if they reside within the same NamingContainer.

The clientID is generated by prefixing the naming container ids seperated by : by default. The p:panel component does not implement NamingContainer although h:form and p:dataTable do implement NamingContainer.

The clientID of myOutputPanel is as follows:

myForm:myOutputPanel

The second button works because it is outside of the dataTable and relative to myOutputPanel in the same NamingContainer which is the form. To reference the absolute clientID in process or update one can prefix the clientID with the : symbol.

Try changing the update attribute of the first commandButton to:

:myForm:myOutputPanel

This should allow it absolutely reference its generated clientID and work.



来源:https://stackoverflow.com/questions/16358535/how-to-update-panel-from-datatable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!