• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

is there something similar to c:forEach in JSF

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,

is there a way to retrieve indexed properties in JSF inside of a loop like structure like c:forEach or logic:iterate so that you can use indexed properties for the h: tags in JSF like #{myBean.property[counter]}

I can't seem to find a way to do this easily

Amarish
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not really. What are you trying to do exactly and maybe we can find a better alternative for you.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Khopker Amarish said:


Hi,

I've looked for this in a lot of places and can't seem to find a solution. I'm trying to do a form with a table that has a dynamic number of rows each with an input radio and input text field which are indexed properties.

Unfortunately I'm on JSP 2.0 and don't currently have the option to switch to 2.1 and upgrade my EL version.

My question is how do you do a for loop or a c:forEach so that these input fields with have a value attribute that is either:

1. indexed like value="#{myBean.values[index].type}"

OR as part of a Collection like

2. c:forEach var='nxt' items='#{myBean.values}'
and then value='#{nxt.type}'

or something to that effect?

Any insight would be greatly appreciated.

Amarish



Why do you need to do this? A dataTable already loops through your collection for you.
 
Khopkar Amarish
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm actually trying to render a table with a dynamic collection of rows having input fields (each row in the collection has a text and radio button). Ideally, I would map the text fields and radio buttons in this collection to item objects in Collections in my bean.

Is a data table the best way to do this?

Amarish
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is a data table the best way to do this?

Yes! A dataTable is for rendering a table based on come collection. Or collection of collections.
 
Your mother was a hamster and your father was a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic