Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Row index in ui:repeat tag

 
Ankit Garg
Sheriff
Posts: 9510
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • 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
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • 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.
 
Rahul Juneja
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Tomahawk has a component which suits your needs.
 
Ankit Garg
Sheriff
Posts: 9510
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • 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...
 
suresh dasari
Ranch Hand
Posts: 121
Chrome Eclipse IDE Mac
  • Mark post as helpful
  • send pies
  • 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)} "
 
Kumaravadivel Subramani
Ranch Hand
Posts: 171
Java Linux Spring
  • Mark post as helpful
  • send pies
  • 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.
 
Ousmane Mbinte
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Yes I see it. What's the expression for display each iteration ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic