• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Row index in ui:repeat tag

 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want urgent solution to this. I am using ui:repeat tag to iterate over a list. Now in that I need to do some processing based on the current iteration index like we have in a normal for loop. I have to do some processing based on the current iteration index. Can anyone tell me how can I get that.

Any help ASAP is welcome

Thanks
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please ease up: http://faq.javaranch.com/java/EaseUp
Urgency is totally irrelevant to us. Moving presurre to us is fairly rude.
 
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
index of ui:repeat is not exposed in the api. if you don;t want to use c:if then the other option is to declare a variable in the bean and then use it.

This has also been in discussion that they should do include this tag in jsf core library itself rather then facelets. Not sure if this is done in JSF 2.0

Thanks,
Rahul
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tomahawk has a component which suits your needs.
 
Ankit Garg
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bauke Scholtz wrote:Please ease up: http://faq.javaranch.com/java/EaseUp
Urgency is totally irrelevant to us. Moving presurre to us is fairly rude.



Oops! I broke a rule

Anyways thanks for the help. I temporarily implemented the action solution that Rahul gave. Actually I was iterating over a list from the action, like this



Since it was a list which is ordered, so I used indexOf to solve my problem



I don't know if this is a proper solution but this is what came to my mind. I'll also try the Tomahawk component that you are saying Bauke. Right now I have some other works so I'm sticking to my solution. Please suggest if my solution would lead to severe performance problems...
 
Ranch Hand
Posts: 121
Mac Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried the same, but not working
it is throwing an error message: "Error 500: Error Parsing: #{backingBeanObject.listObject.indexOf(var)} "
 
Ranch Hand
Posts: 171
Spring Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem is solved in JSF2 frame work by "varStatus" attribute in ui:repeat tag. For more details refer the below links:

http://www.mkyong.com/jsf2/jsf-2-repeat-tag-example/
http://javaserverfaces.java.net/nonav/docs/2.0/pdldocs/facelets/ui/repeat.html

I had the same problem and got working as expected. I'm quite happy to have this feature and helped me a lot.
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Yes I see it. What's the expression for display each iteration ?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic