Reputation: 3107
I would like to call a method of a Bean and then, redirect the user to another page that is determined at runtime when this method is called and derived by some runtime calculations: For example:
on the .xhtml:
<p:selectBooleanCheckbox value="#{userAuth.parameterA}"/>
<p:commandButton value="Save Changes"
id="withIcon"
type="submit"
actionListener="#{userAuth.saveChanges()}"
icon="ui-icon-disk" />
on the bean:
public String saveGhanges(){
this.entity.save(); //dummy code)
if (this.parameterA == true) return "ATrue.xhtml";
if (this.parameterA == false) return "AFalse.xhtml";
}
Upvotes: 3
Views: 1522
Reputation: 304
try this:
<p:selectBooleanCheckbox value="#{userAuth.parameterA}"/>
<p:commandButton value="Save Changes"
id="withIcon"
type="submit"
action="#{userAuth.saveChanges()}"
icon="ui-icon-disk" ajax="false"/>
actionListener should be for void methods. i hope it helps.
Upvotes: 4
Reputation: 12204
Just like @pamps said, try replacing actionListener
with action
in your commandButton
actionListeners
have void
return type, while actions
may have void
or String
as their return type!
Hope this helps!
Upvotes: 2