Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Different parameters in c:forEach  RSS feed

 
Johan Rignas
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! Is there any way I can have different parameters for objects in a c:forEach loop?
Example:

Any tips or idea to achieve this?
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Johan Rignas wrote:
Any tips or idea to achieve this?


Yes.

Don't do it.

JSTL and JSF do not play nice together. Don't use JSTL with JSF.

When you have multiple elements to display in a JSF view, use a dataTable if it organizes on the page as a 2-dimensional table (including single-column vertical list). Otherwise use the Facelets ui:repeat tag. In the case of a dataTable, you can include the "draggable" property value as a column in the table's DataModel. Which is the recommended way, since logic has no business being in the View template.
 
Johan Rignas
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for reply. I´m not sure I follow you. But I have now changed to a dataTable now looking like this:

And I would like to have it draggable iff my myElem is a specific value. Is possible to solve somehow?
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't have columns without rows. You need AT LEAST one row or the table won't render. A "value="" won't do what you want.

You could use EL to do what you want:


However, as I said, it's not a good idea to put logic in the View template. Aside from polluting MVC, it's a bugger to debug. Better is to handle it in the datamodel and simplify the EL:
 
Johan Rignas
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dont manage to do the bean solution so I go for EL by the moment. It works great. Thanks!!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!