This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes JSF and the fly likes Resolving EL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Resolving EL" Watch "Resolving EL" New topic

Resolving EL

srinivas bodapati

Joined: Jul 09, 2008
Posts: 14
Hi all,

I have two command buttons on my jsp, which I should show or hide based on the user action for which I have set a property in by backed bean.

i am using the rendered tag for this, the logic works fine

I mean the buttons are displayed accordingly, but one of the button does not work having the particular expression in the rendered tag,
below is my code....

<hx:commandExButton type="submit" value="Save"
styleClass="commandExButton" id="button1"
rendered="#{empty manage_News.actionType}"/>
<hx:commandExButton type="submit" value="Update"
styleClass="commandExButton" id="button2"
rendered="#{not empty manage_News.actionType}" />

the save button works good,

coming to the UPDATE button it is shown or hide accordingly based on the expression and what I expect

but the update button never hit my action having this particular expression,

if I change the expression like #{empty manage_News.actionType} it is displayed accordingly and also works fine,

can any one help me with this EL or if is there any problem with using 'not empty'

thank you.

Perception Matters.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
The rendered attribute is also determined during apply request values phase of the subsequent request (the form submit). You need to make sure that the getter behind the rendered attribute returns the same value as it did in the initial request (for display). Change the bean's logic, or use h:inputHidden with binding, or Tomahawk's t:saveState, or -more ridiculous-, set the bean in the session scope instead of request scope.
[ December 18, 2008: Message edited by: Bauke Scholtz ]
srinivas bodapati

Joined: Jul 09, 2008
Posts: 14
thanks for the reply agin,

I don't think its the problem with scope,

If it is so, the logic should not work at all, I mean the button should not show up or should show up all the time.

But the display works fine, the buttons functionality is not working-- the button is not calling the action it is supposed to if I have this particular expression in the rendered tag.

That works fine if change the expression or remove it completely.

I hope you got what I am trying to explain here.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Read on about the JSF lifecycle and then reread my answer.
I agree. Here's the link:
subject: Resolving EL
It's not a secret anymore!