This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Nested hashmap tags for dynamic pulldowns

 
Lee Wright
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • 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 ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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='<cut value="${list.value}"></cut>'> <cut value="${list.label}"></cut></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="<cut value='${bean.value}'/>">
<cut value="${bean.label}"></cut>
</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
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic