I am attempting to create a set of checkboxes using <h:selectManyCheckbox>. The checkboxes are being generated from a database table and there are 20 to 30, but the only layout is everything in one row, or one column. I have searched this forum, and the internet in general, and the question has been asked several times. The best answer seems to be to use Tomahawk, but according to other threads in this forum, Tomahawk has issues with JSF 2.0 (I am using the Sun RI). Other solution are to write a custom renderer, or a custom UI component. That seems like an enormous amount of work (especially for someone who is still learning the basics of JSF) for something that should be incredibly simple. Am I missing something? Some simple JSF technique that will make this work? I have been very impressed with JSF 2.0 until this point.
I cannot believe that I am the only person to have had this problem. Can anyone point me to a good solution? I am about ready to roll up my sleeves and write a custom UIComponent. Something like SimpleCheckbox. All that it will need to output is:
and then I can use a <h:panelGrid> for layout. Of course, it should do everything that the <h:selectManyCheckbox> already does. Can some of you more experienced JSF programmers tell me if this sounds like the proper solution? Or am I over-engineering a solution? I would prefer an already packaged solution, since my job is to write a website, not write UI Components.
Any advise will be appreciated.
Joined: Oct 26, 2009
Well, I have come up with a solution. I do not particularly like it, but it does seem to work. Once again, for you more experiences JSF programmers, please tell me if there is a better solution. What I have done is to break the checkboxes into two group and use two separate <h:selectManyCheckbox> tags. The HTML is as follows:
From the backing bean, I wrote the following code:
This is a bit complicated for setup, but does work. Is there a better solution available now? I suspect long-term I will use Tomahawk when it is stable with JSF 2.0.