0

I have a primefaces datatable with a <p:rowEditor />. The Logic of my process is when i click on a button it's suppose to:

  1. Jump to the last page of the Datatable
  2. Refresh the table
  3. Click on the edit button of the last row

in the footer i implemement a commandButton and remoteCommand looking like:

<f:facet name="footer">
    <p:remoteCommand name="rctype" update="typeDT" 
     actionListener="#{myView.onNewType}" />
    <p:commandButton id="btnNewType" ajax="true" onclick="rctype()"
     update="typeDT" icon="ui-icon-plus" title="New Type" 
     value="New Type" >
    </p:commandButton>
</f:facet>

my Bean looks like :

public void onNewType() {
    try {
        ...
        RequestContext.getCurrentInstance().execute("PF('widgettypeDT')
         .paginator.setPage(PF('widgetinitiatorDT').paginator.cfg.pageCount - 1)");

        RequestContext.getCurrentInstance()
                    .execute("jQuery('.typeClass')
                    .find('span.ui-icon-pencil').last().click();");
    } catch() {}
}

But unfortunatly the Click Event always occur before the Jump Event.

How can i control the Execution order of my Javascript Events in my Managed Bean?

3logy
  • 2,384
  • 4
  • 37
  • 86

1 Answers1

0

The solution is simple. Call one javascript function on the client and do both in there. Or do both in one RequestContext.getCurrentInstance().execute(...)

Kukeltje
  • 11,924
  • 4
  • 19
  • 44
  • Already tried it too! With the same result!! The Click Event always occurs before the Jump Event – 3logy Nov 04 '15 at 08:54
  • Thanks for mentioning you already tried that. In that case what you describe is not what actually happens but it is what you observe – Kukeltje Nov 04 '15 at 10:53
  • Thx! this is the reason, why i do not understand the current behavior. I also tried delay... same result or an error occurs. – 3logy Nov 04 '15 at 11:39