This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSF and the fly likes selectManyCheckBox within a panelgrid? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "selectManyCheckBox within a panelgrid?" Watch "selectManyCheckBox within a panelgrid?" New topic

selectManyCheckBox within a panelgrid?

Anthony Smee

Joined: Oct 01, 2009
Posts: 4
Hi there

I am quite new to JSF and am currently struggling to get my long list of check boxes spread over a grid rather than in one line either horizontally or vertically off of the page. The list is in excess of 40 check boxes and I would to show them in a grid/table say 10 columns wide.

I have looked at panelGrid and have set this up, but I cannot work out how to display the checkboxes as I have described?

My code:

<h:panelGrid columns="8" footerClass="subtitle" headerClass="subtitlebig" styleClass="medium" columnClasses="subtitle,medium" style="width:100%">
<f:facet name="header">
<hutputText value="Current Stop Words" />
<h:selectManyCheckbox id="StopWords" value="#{UserBean.stopWords}" >
<f:selectItems value="#{UserBean.stopWords}" />

With my UserBean looking like this:

public List<SelectItem> getStopWords()
return f.stopWords;

Where f.stopWords is:

List<SelectItem> stopWords = new ArrayList<SelectItem>();

and is populated with:

private void setupStopWords()
for (int i = 0; i < exclusionWords.length; i++)
stopWords.add(new SelectItem(i,(String)exclusionWords[i]));

To confirm, my checkbox works, I just want to know how to change the display of the checkboxes over multiple columns? If anyone could advise, or a URL link to a decent tutorial (I can't find one through google), or perhaps I am going about this the wrong way?
Abhishk Gupta

Joined: Oct 08, 2008
Posts: 22
Hey Anthony...though you have put much effort in explaining the problem but unfortunately I could not get the clear picture.

Would it be possible for you to give a pictorial representation of your requirement coz I feel this can be easily done using a datatable.

There are only 10 types of people in the world: those who understand ternary, those who don't, and those who mistake it for binary.
Anthony Smee

Joined: Oct 01, 2009
Posts: 4
Hi there

Thank you for your reply, I forgot to update this forum with the outcome of another:

And a picture is attached.

[Thumbnail for mutli-ticks.jpg]

I agree. Here's the link:
subject: selectManyCheckBox within a panelgrid?
Similar Threads
horizontal alignment
JSF Checkbox Group
selectManyCheckbox in dataTable returns only the last selected item rather the whole list.
How to limit no of rows in colu if rows increases more than 7 using JSF & the new value in new colu?
box layout using HtmlPanelGroup