0

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);
    }
}
Sinda MOKADDEM
  • 796
  • 2
  • 12
  • 35

2 Answers2

1

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.

tt_emrah
  • 1,043
  • 1
  • 8
  • 19
  • I already tried action and actionListener instead of onStart, and no one worked. They don't call the method. That's very strange because I checked the method signature and it's alright – Sinda MOKADDEM Jul 14 '14 at 11:35
  • could you paste the code of whole form `Button1` is nested in? – tt_emrah Jul 14 '14 at 11:37
  • I edited my question and added the structure of my xhtml page... maybe it would offer some clarification – Sinda MOKADDEM Jul 14 '14 at 11:43
  • 1
    yes, using `process="@this"` was my second alternative. that attribute decides which fields will be submitted with that request. if you do not set it to `@this`, all the form that the button is nested in will be submitted to server side. in that case, it messes up with a lot of things. – tt_emrah Jul 14 '14 at 14:53
0

Problem solved by using actionListener AND process="@this" attribute of the commandButton.. But I honestly don't know why it worked only by adding process="@this".. If someone knows the reason.. please let me know. Thanks to all.

Sinda MOKADDEM
  • 796
  • 2
  • 12
  • 35
  • Next time post a [MCVE](http://stackoverflow.com/help/mcve) and you'll get better help sooner. See also our [jsf info page](http://stackoverflow.com/tags/jsf/info) – perissf Jul 14 '14 at 14:12
  • Thank you @perissf but I thought that the code I posted was enough to illustrate the problem. Isn't it? – Sinda MOKADDEM Jul 14 '14 at 14:50
  • The default is @form so that sounds very strange. Try deleting it again – Jaqen H'ghar Jul 14 '14 at 14:56
  • An idea could be that when using @form one of the other input fields causes an exception, causing the method to not be run – Jaqen H'ghar Jul 14 '14 at 15:40