What is the best way to put the index value of a collection in a
select options list? I'm currently doing this:

<html:select styleClass="field" property="userTypeId">
  <logic:iterate id="element" name="userTypes" indexId="index" >
    <html:option value="<%= index.toString() %>">
      <bean:write name="element" property="displayName"/>
    </html:option>
  </logic:iterate>
</html:select>

I don't like the above since it requires the scriplet. I suppose I
could give my form bean an indexId attribute so when it's populated
into the collection I later could do:

<html:select styleClass="field" property="userTypeId">
  <html:options collection="userTypes"
      property="indexId" labelProperty="displayName"/>
</html:select>

The later seems cleaner in the presentation view but for some reason
it doesn't sit right with me for a bean to have to keep a field for
knowing what place it might hold in a Collection. I take it I'd also
have to call setIndexId( i++ ) or something similar whenever I add
these beans to the collection. Seems like that shouldn't be something
a bean should have to worry about, but I'm probably wrong:)

How do you guys handle this?

TIA

--

Rick

mailto:[EMAIL PROTECTED]


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to