• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can you have condition in <h:selectOneMenu> ?

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No can't do by following this way......
 
author
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 27707
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

reply
    Bookmark Topic Watch Topic
  • New Topic