• 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

Nested hashmap tags for dynamic pulldowns

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to get a page working that has two pulldowns.
The first is a static list of values held in a List and the second is a HashMap with the keys matching values of the first List array.

I can get the list to display all items in the Hash:

<html:select indexed="true" name="requestList" property="event" >
<c:forEach var="key" items="${requestForm.events}">
<option><c ut value='key=${key.key}, value=${key.value}'/></option>
</c:forEach>
</html:select>

This alone took way too much time...but now I need to limit the values to those that match a previous List box...


Help...!!
[ November 30, 2004: Message edited by: Bear Bibeault ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

but now I need to limit the values to those that match a previous List box...



It's not clear whay you mean by this, but regardless, if there is any data filtering to be done it should be done when the collections are created rather than on-page.
 
Lee Wright
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem is that the pge will have multiple lines and each line will have a different location pulldown.
I wanted to avoid having multiple copies of the lists which is why I wanted to put them into a single HashMap.

I got this far:

<html:select indexed="true" name="requestList" property="event" >
<c:forEach var="key" items="${requestForm.events}">
xx[<c ut value="${requestList.location}"></c ut>]xx

yy[<c ut value="${key.key}"></c ut>]yy
<c:if test="${requestList.location}=" + <c ut value="${key.key}"></c ut> >
<option>Matched</option>
</c:if>
<option><c ut value='key=${key.key}, value=${key.value}'/></option>
</c:forEach>
</html:select>

xx[10]xx and yy[10] are matching but not appearing as equal in my test="" clause.

Thanks

L
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I wanted to avoid having multiple copies of the lists which is why I wanted to put them into a single HashMap.



Why? If they are distinct abstractions, why mash them all together to be sorted out later?

By the way, if you click the 'disable smilies' box on your posts, your tags will look less surprised.
 
Lee Wright
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its because the list is dynamic from a database lookup.
This creates then populates an Array of possible options, then the ID values for each of these are used as the key for the dynamic HashMap.
This HashMap then contains:

[ 1 ] [ Array of LabelValueBeans ]
[ 2 ] [ Array of LabelValueBeans ]
[ 3 ] [ Array of LabelValueBeans ] ... etc..

When item with id 1 is selected I want the secondary pull-down to display the ArrayList of LabelValueBeans.

Hope that makes sense..
 
Lee Wright
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I found the solution to my problem. I've posted it just incase anyone else is facing similar problems doing dynamic matching in JSTL:

<html:form action="iterate.do" method="POST">

<html:select onchange="document.forms[0].submit();" name="selectOne">

<c:forEach items="${iterateActionForm.listIterator}" var="list">
<option value='<c:out value="${list.value}"></c:out>'> <c:out value="${list.label}"></c:out></option>
</c:forEach>
</c:set>

</select>

<select name="selectTwo">
<c:forEach items="${iterateActionForm.complexIterator}" var="keys">
<c:choose>
<c:when test="${keys.key == iterateActionForm.selectOne}">
<c:forEach items="${keys.value}" var="bean">
<option value="<c:out value='${bean.value}'/>">
<c:out value="${bean.label}"></c:out>
</option>
</c:forEach>
</c:when>
</c:choose>
</c:forEach>
</select>

The key here is the test clause is using a value set by the previous select html tag.

Lee
 
look! it's a bird! it's a plane! It's .... a teeny tiny ad
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic