Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Resolving EL

 
srinivas bodapati
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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"
action="#{manage_News.insertNews}"
rendered="#{empty manage_News.actionType}"/>
<hx:commandExButton type="submit" value="Update"
styleClass="commandExButton" id="button2"
action="#{manage_News.insertNews}"
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.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read on about the JSF lifecycle and then reread my answer.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic