• 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
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Getting value of radio button to JSTL c:if

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have

<h:selectOneRadio id= "gSelect">
   <f:selectItem id= "one" itemlabel="abc" itemValue ="ABC"/>
   <f:selectItem id= "two" itemlabel="xyz" itemValue ="XYZ"/>
</h:selectOneRadio>

c:if test ="when radio selection equals abc"
do stuff

need help with the c:if test
 
Rancher
Posts: 4801
50
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where are you expecting this if test to be done?
 
Drew Jonas
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to check to see which radio button was check and grab that value to be used for a property in a bean on submit
 
Drew Jonas
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The if test is on same jsp as radio
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
c:if is probably not the best way to do whatever exactly you want to do. In fact, it's better to not use the JSTL tag libraries in JSF at all (certainly not if you are using a newer JSF version).

Why not bind the value of the selectOneRadio component to a property of one of your beans:

That way, whenever the page is submitted, the 'someProperty' property of bean 'myBean' will automatically be set to the selected radio button value ("ABC" or "XYZ"). If you need more logic, you can put that in your Java code in beans instead of in your Facelets pages. Beans are the right place to program business logic.
 
reply
    Bookmark Topic Watch Topic
  • New Topic