File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Row index in ui:repeat tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Row index in ui:repeat tag" Watch "Row index in ui:repeat tag" New topic
Author

Row index in ui:repeat tag

Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9321
    
  17

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


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
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

Joined: Aug 03, 2002
Posts: 425
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


Rahul Juneja
ThoughtClicks - http://techlabs.thoughtclicks.com
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Tomahawk has a component which suits your needs.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9321
    
  17

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

Joined: Oct 05, 2009
Posts: 121

I tried the same, but not working
it is throwing an error message: "Error 500: Error Parsing: #{backingBeanObject.listObject.indexOf(var)} "


Sun Certified Java Programmer with 93 percent
Kumaravadivel Subramani
Ranch Hand

Joined: Jul 05, 2008
Posts: 166

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.


No pain, No gain.
OCJP 1.6
Ousmane Mbinte
Greenhorn

Joined: Jan 13, 2014
Posts: 18
Hello,

Yes I see it. What's the expression for display each iteration ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Row index in ui:repeat tag