• 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

Styling h:selectOneListbox

 
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Happy New Year and hello Ranchers, this is my first posting for 2013.

I have an issue with styling h:selectOneListbox and would most appreciate some advice. Hopefully it should be easy to answer, but I cannot find an obvious solution. In my bean I have a fragement of code as follows:

which works correctly and sets some items I want displayed to be disabled, although most are enabled. In fact the items are the 92 chemical elements from Hydrogen to Uranium, but several of them have abundances that can be completely neglected, such as Promethium. I still want these displayed in the menu, but disabled.

In the xhtml code here, I have a class for the enabled and disabled entries:

with the corresponding styles set here:

Using Firefox the items are formatted correctly, with the disabled items also being formatted, but grayed out. For some reason, even though the style itemDisabled is exactly the same as itemEnabled, it is still grayed out. If itemDisabled is omitted, it is still grayed out, but not monospaces, which is to be expected.

However, using Internet Explorer or Chrome the text is not monospaced, neither the enabled or disabled text. How do I fix that? Also, I notice that the attributes for h:selectOneListbox also include styleClass, but how does that fit in with enabledClass and disabledClass?

Some advice would be most appreciated - many thanks.
 
Saloon Keeper
Posts: 27764
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
styleClass is the master style for the control. It should convert to "class=" on the generated HTML SELECT tag. The other styles are for internal components, and usually would cascade back the the styleClass.

Browser-specific quirks are not indulged by the core JSF tagset - you'll get the same results as if you had coded simple SELECT and OPTION tags. The best way to tweak things is to do a View Source on the resulting page and see what HTML was generated, then play with the JSF options until you get what you like. Which may not be what you want, since there are limits to how much basic HTML can be tweaked for any given browser. That's the browser's fault, not JSF's.
 
Christopher Sharp
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, many thanks, and that is something I will look into. In fact as I am starting to convert some of the tags to PrimeFaces, that may also be a solution.

In the mean time a more serious issue has turned up, and will post this on another thread.

Many thanks.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic