aspose file tools*
The moose likes JSF and the fly likes Styling h:selectOneListbox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Styling h:selectOneListbox" Watch "Styling h:selectOneListbox" New topic
Author

Styling h:selectOneListbox

Christopher Sharp
Ranch Hand

Joined: Dec 12, 2007
Posts: 152
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.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019
    
  20

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Christopher Sharp
Ranch Hand

Joined: Dec 12, 2007
Posts: 152
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Styling h:selectOneListbox