-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Looping through a List
PostPosted: Tue May 25, 2010 5:38 pm 
Newbie

Joined: Tue Mar 17, 2009 1:56 pm
Posts: 6
Hi

I'm new to this. I have a Person object with a List of dogs of type Dog. I'm successfully getting the Person I want and accessing all their dogs from the List.

1. I'm using the id column as the index, and I've just realized that unless the List of dogs contains ids sequentially, starting with 0, I get an error when trying to access the List. Makes sense, fair enough. Do I really have to maintain an idx column on the table purely for this purpose, or is there a better way?

2. I've put the Person into a command object and I'm accessing it in the form like this :-

Code:

<c:forEach items="${person.dogs}" var="i" varStatus="itemsRow">
      <form:input path="dogs[${itemsRow.index}].name"/><form:input path="dogs[${itemsRow.index}].type"/></br>
</c:forEach>



How do I loop through the dogs in alphabetical name order?

Many Thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.