1

What I want is commandButton should complete the action first and then update dataTable, but it is actually updating dataTable before the action is performed. Can someone please suggest how to do this?. Thanks.

<p:dataTable id="files" var="file" value="#{tableBean.lstFiles}" rowKey="#{file.fname}" selection="#
     {tableBean.selectedFile}"  selectionMode="single"  > 

    <p:ajax event="rowSelect" listener="#{tableBean.onRowSelect}"  />
    <p:ajax event="rowUnselect" listener="#{tableBean.onRowUnselect}"/>

     <p:column headerText="Date"> #{file.fname}</p:column>  
     <p:column headerText="Type"> #{file.ftype}</p:column>  
     <p:column headerText="Date"> #{file.fdate}</p:column>  
    <p:column headerText="View File" >
  <p:commandButton id="folder" action="#{folderName.name}" value="Open" update=":form2:files" icon="ui-icon-arrowthichk-s"  >                   
         <f:setPropertyActionListener target="#{folderName.foldername}" value="#{file.fname}" />
                    </p:commandButton>
                </p:column>  

            </p:dataTable> 
tkanzakic
  • 5,499
  • 16
  • 34
  • 41
Ankita Jain
  • 13
  • 1
  • 9
  • Look at this [answer](http://stackoverflow.com/a/3909382/1692632). Your actionListener should be first executed – Darka Jan 17 '13 at 13:11
  • How did you confirm this is what is really happening? – kolossus Jan 17 '13 at 14:06
  • @Darka Thanks for the help but what i want is on button click file.fname should be the new value of instance variable of tableBean class and actionlistener is not helping me out. – Ankita Jain Jan 17 '13 at 14:38
  • @kolossus I am using system.out.println statements to see the sequence of execution. – Ankita Jain Jan 17 '13 at 14:42
  • You mean it renders the dataTable and after that the action is performed or what ? Standart JSF lifecycle (simplified, not all phases) is working like this : retrieve changed values + convert them -> validation -> update model values -> perform business logic (action is executed here) -> render response – Fallup Jan 17 '13 at 15:35
  • @Fallup yes datatable is updated first then action is performed but i want action to be performed before updating datatable. – Ankita Jain Jan 17 '13 at 15:40
  • How can you say that update is performed before action ? Either it is not or action is not called at all. – Fallup Jan 17 '13 at 16:12
  • @Fallup Because i am using println statements to view the sequence of execution. – Ankita Jain Jan 17 '13 at 16:33
  • @AnkitaJain,Interesting. what you're stating here seems(to me) to be technically impossible. DOM updates usually happen at the tail end of the lifecycle after actions/actionListeners have been processed. How exactly are you tracking the DOM updates on the server side? The only instance where the DOM will be refreshed without action(listeners) being fired is when a conversion/validation error causes the form processing to choke. Please share here, how you're confirming that the actionListener is firing **and** model and DOM updates are taking place, albeit out of sync – kolossus Jan 18 '13 at 08:24

0 Answers0