CommandButton : EL expression for Update

UI Components for JSF
Post Reply
denisduval75
Posts: 109
Joined: 08 Nov 2016, 16:53

30 Oct 2017, 08:06

Hello,
On a commandbutton, I want to condition the value 'update' according to a boolean, like this:

If boolean is true: <p: commandButton ... update = "a b c">
If boolean is false: <p: commandButton ... update = "d e f">

I do not know how to code the EL expression. Something like this:

<p: commandButton ... update = "# {bean.boolean == true: a b c, bean.boolean == false: d e f}"

Thanks a lot for your help.

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

30 Oct 2017, 10:30

Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

Hamsterbau
Posts: 409
Joined: 28 Dec 2011, 17:44

30 Oct 2017, 13:04

For a JSF beginner it can be confusing, but you can simply use shorthand if (like mentioned above) to return 2 different strings:

Code: Select all

#{bean.boolean ? 'a b c' : 'c d e'}
Primefaces 8.0.7 (PF Extensions 8.0)
JSF: Mojarra 2.3.2 (Spec 2.3) - running on WildFly 22

denisduval75
Posts: 109
Joined: 08 Nov 2016, 16:53

03 Nov 2017, 08:08

Thank you very much !

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 26 guests