1

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>
Turgut Dsfadfa
  • 775
  • 6
  • 20
  • 42

1 Answers1

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.

maple_shaft
  • 10,435
  • 6
  • 46
  • 74
  • I am getting this error. "Cannot find component with identifier ":myForm:myOutputPanel" referenced from "tabView:myDatatable:0:myButtonId"". By the way this page is inside a tab and tabview's id is "tabView". – Turgut Dsfadfa May 03 '13 at 12:28
  • I tried also "tabView:myOutputPanel" and ":tabView:myOutputPanel" and ":myOutputPanel". None of them worked. – Turgut Dsfadfa May 03 '13 at 12:35
  • @TurgutDsfadfa TabView is also a NamingContainer but it is build on a `ui:repeat` so you can't directly access an absolute clientID for this. You would either need to update the entire TabView or you can use the `@form` reserved value to update all elements inside of `myForm`. – maple_shaft May 03 '13 at 12:39
  • 1
    Try :myForm:tabView:myOutputPanel – Jitesh May 03 '13 at 18:32