Search code examples
jsfprimefacescommandbuttononstart

onStart method is called AFTER onComplete method


I have a button let's call it "Button1":

<p:commandButton icon="ui-icon-document"
  value="Button1"
  onstart="#{bean.populateDependancies(item)}"
  update="myDialog"
  oncomplete="dialogWidget.show();">
</p:commandButton>

This Button1 is supposed to open a dialog, but BEFORE opening it I want it to populate the target of the primefaces picklist in the dialog with some values (this job is done by the method populateDependancies(item)).

But actually the method populateDependancies(item) is called when I close the dialog and hit the validateEdition button of cellEditor of primefaces (or even the cancel button) (NB: Button1 is placed in a column of an editable datatable).

I hope I clearly explained the problem... Please let me know if something remains unclear


Here is my page structure maybe it could help: enter image description here

and here is my method:

public void populateDependancies(Release release) {
    if (release != null) {
        if (rfcsDualListModel.getTarget() != null || !rfcsDualListModel.getTarget().isEmpty()) {
            rfcsDualListModel.setTarget(null);
        }
        List<Rfc> rfcDejaAssocies = release.getRfcs();
        rfcsDualListModel.setTarget(rfcDejaAssocies);
    }
}

Solution

  • onstart executes javascript code, just like oncomplete. #{bean.populateDependancies(item)} must be the value of action or actionListener attributes.

    edit: in addition, process="@this" attribute and value must be used, in order not to submit the whole form.