Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Can you have condition in <h:selectOneMenu> ?

 
J James
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I'm trying to put condition in selectOneMenu and failing quite miserably. Can someone enlighten me if this is even possible? I’m getting the one selected value from Bean file as I should but I need to display two further more choices for an update. Here’s my current code.
Many thanks
JJ
 
Aman Goel
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No can't do by following this way......
 
Bart Kummel
author
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi J,

I don't understand what exactly is your problem. However, I have a hint for you... Are you aware that there is also a <f:selectItems> component, that adds a list of items in one pass?

Best regards,
Bart
 
J James
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your replies , This is an update page I'm working on, the problem is I'm trying to put condition in <h:selectOneMenu> so if the value of <f:selectItem> is equal to lets say 'APPT' put the label to 'Appointment' and give them two more choices so they could update if they wish, like so;


This code doesn't work. How do I do this ???



Bart Kummel wrote:Hi J,

I don't understand what exactly is your problem. However, I have a hint for you... Are you aware that there is also a <f:selectItems> component, that adds a list of items in one pass?

Best regards,
Bart
 
Bart Kummel
author
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Perhaps you could try this:

Note that I removed the <c:choose> and moved your condition to the rendered attribute of each <f:selectItem>. Alse notice the } that moved to the end of the expression. I hope this helps...

Best regards,
Bart Kummel
 
Tim Holloway
Bartender
Posts: 18419
60
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mixing JSTL and JSF in the same view is almost always bad practice. So is putting application logic in the view.

As Bart said, you should consider building your selectItem list in a backing bean instead of on the page definition. It's much more flexible and easier to do as well.
 
J James
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your help Bart unfortunately I'm getting the following error. I don't think it likes rendered



jj


Bart Kummel wrote:Hi,

Perhaps you could try this:

Note that I removed the <c:choose> and moved your condition to the rendered attribute of each <f:selectItem>. Alse notice the } that moved to the end of the expression. I hope this helps...

Best regards,
Bart Kummel
 
Bart Kummel
author
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I forgot the <f:selectItem> component doesn't have a rendered attribute. Then I guess there's no other option than creating your list in code and use a <f:selectItems>. That's a better solution anyway, as Tim mentioned correctly.

Best regards,
Bart
 
J James
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for all your help guys, I'll have to work in backing bean.

JJ

Bart Kummel wrote:Sorry, I forgot the <f:selectItem> component doesn't have a rendered attribute. Then I guess there's no other option than creating your list in code and use a <f:selectItems>. That's a better solution anyway, as Tim mentioned correctly.

Best regards,
Bart
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!