Reputation: 813
I have a problem. I have a JSF Primefaces environment, and I would like to set the password. In the bean there is a method, it can throw exception or set the doneChange boolean to true.
I want the following run:
If the doneChange boolean is true, just close the dialog where the button is, and open an another.
Here is the code of the button:
<p:commandButton id="changeButtonId"
type="submit"
value="#{msg.changePassword}"
ajax="true"
action="#{changePasswordController.changePassword}"
update=":changePasswordFormId :actionSuccessDialogId"
oncomplete="if(#{changePasswordController.doneChange}){actionSuccessDialogVar.show()}; if(#{changePasswordController.doneChange}){changePWDialog.hide();}">
<f:setPropertyActionListener target="#{functionSuccessBean.actionName}" value="#{msg.changePassword}"/>
<f:setPropertyActionListener target="#{functionSuccessBean.description}" value="#{msg['actionSuccess']}"/>
</p:commandButton>
the problem is: I debugged when I click on this button, before the oncomplete called the doneChange set to true. I have only one suspection: when the button is rendered, the oncomplete event is determined. Because when I open this dialog again, that doneChange is still true and works as I want. I ran out of ideas how to make it work.
How can I make it react the doneChange boolean in real time? Does it work with some binding? I tried primefaces home tutorials but with no success.
Thanks in advance
Upvotes: 1
Views: 8497
Reputation: 813
I found a solution by a help of a non-stackoverflow friend. It appears I used it wrong way, and needed to add a callbackparam.
I needed to add in the Bean:
RequestContext.getCurrentInstance().addCallbackParam(
"doneChangeParam",
doneChange
);
And oncomplete changed to:
oncomplete="if(
args && args.doneChangeParam)
{
actionSuccessDialogVar.show(); changePWDialog.hide();
}"
Upvotes: 3