• 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

How can I display this using SelectOneRadio?

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What I need is a layout like this:



Notice that it has 3 elements grouped together. When I use the SelectOneRadio I can't get it to render anything more than 1 input element. The following produces all elements before a table element with the table element containing all the radio buttons.



So how can I do this in JSF?
 
Saloon Keeper
Posts: 27807
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
I just reviewed the Oracle docs. They're awful.

The selectOneRadio generates an HTML table (not an HTML list). The elements within the table are rendered from the f:selectItem child elements.

Members of the "f" tag library do not generate HTML. They may contain data that is used by container elements as part of the container rendering process, as is true in this case, but they don't directly render anything. You'll notice that there are no rendering attributes for selectItem except for the "disabled" attribute.

Simply jamming HTML into the body of the JSF tag won't work. I don't recommend mixing JSF and HTML to begin with, but in this case, the tag is so abstract relative to what gets generated that there's simply no meaningful place to put stuff like that.

There may be SOME hope, though. Try this:



The "escape=false" attribute allows you to use raw HTML in the itemLabel. Unfortunately, this is XML, so you must use the entity escapes or it won't parse properly. Don't forget the ";" that terminates each entity.
 
Rob Micah
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah this is awful all the way around. Really I don't necessarily have to have a list element I just need a containing box for the radio button and 2 other elements with it. Or even a table that had a row with those 3 elements in the same row might work.
 
Tim Holloway
Saloon Keeper
Posts: 27807
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
The hard part is getting the radio action where selecting one pops up the others.

There are 2 ways you could deal with this.

1. Apply CSS to set the image elements on each HTML radiobutton element under that control.

2. Render a panelGrid and checkbox controls with Javascript attached to do the 'pop up' function and CSS to provide alternative (radiobutton-shaped) checkbox images.
 
Rob Micah
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I found the best way. I used a h:inputHidden element within a <div> with an id on it. Then I created the radio buttons and their layouts myself. I hooked some javascript (jQuery) onto the change event of the radios and changed the value of the hidden element to match the radio in the event handler. It works so far and is much smaller and cleaner. Here's the code:

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic