Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

c:forEach builds s:selectMany

 
nimo frey
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a problem:
I build this
<blockquote>code:
<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="#{i.name}" itemValue="#{i.id}"/>
</c:forEach>
</h:selectManyCheckbox>
</h:column>
</pre>
</blockquote>

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:

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

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

Any ideas? I need to insert the selectItems into the column!
 
nimo frey
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 facelets..is there a tag, which ensures me the association between h:selectManyCheckbox and f:selectItem ??
 
nimo frey
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18152
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic