File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes c:forEach builds s:selectMany Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "c:forEach builds s:selectMany" Watch "c:forEach builds s:selectMany" New topic

c:forEach builds s:selectMany

nimo frey
Ranch Hand

Joined: Jun 28, 2008
Posts: 580

I have a problem:
I build this
<pre name="code" class="core"><h:column>
<h:selectManyCheckbox id="n" value="#{bean.selectedItems}" layout="pageDirection">
<c:forEach items="#{bean.list}" var="i" >
<f:selectItem itemLabel="#{}" itemValue="#{}"/>

but after selecting, only the Items of the LAST column are collected into the list "selectedItems". Is there any possibility to store the selected values elsewhere? My Client-HTML shows individual ID's for every f:selectItem-Tag. When I insert a id:

<pre name="code" class="core"><f:selectItem id="static" itemLabel="#{}" itemValue="#{}"/></pre>

then the error "duplicate Id for a component.." occurs.

Any ideas? I need to insert the selectItems into the column!
nimo frey
Ranch Hand

Joined: Jun 28, 2008
Posts: 580
I mean, "...are collected into the list "selectedItems", when I choose Items. When I choose Items, which are in the other rows, then these does not appear in my list "selectedItems". I use there a tag, which ensures me the association between h:selectManyCheckbox and f:selectItem ??
nimo frey
Ranch Hand

Joined: Jun 28, 2008
Posts: 580
Is there an alternative way,
to collect data from the selected checkboxes?

I am not sure bout the many tags,
such as f:attribute, f:param, f:facet or the binding-attribute.

Exists (a best-practice) way
to collect the data independently
from the the component selectManyCheckbox?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

Yes. Don't use JSTL. JSTL and JSF don't mix well.

Instead of coding logic on your display page, define the display as a JSF datatable.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: c:forEach builds s:selectMany
It's not a secret anymore!