struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Mok <>
Subject Dynamic lookup tag lib (drop down list reverse)
Date Sat, 10 Jul 2004 13:55:57 GMT
Hi all

I have created a jsp tag that will look up a collection (of  
LabelValueBeans) and return the label of the value. For example we store 
position description in a code table such as
Code  Description
1        Director
2        Manager
3        Assistant Manager
4        Staff

In the User table, we store
Logon      Position
Jack         1
Jill             2
Charlie      2

In a UserList.jsp

<logic:iterate ...>
Logon : <bean:write  name="user" property="logon"/>
Position: <bean:write name="user" property="position"/>

This will produce the following list
Logon : Jack     Position:  1
Logon : Jill         Position: 2
Logon : Charlie  Position: 2

To display the position description instead of the position number, I 
added a list of LabelValueBeans to the session (ie 
session.setAttribute("session.positionlevel"); ) and changed the JSP to 
the following.

<logic:iterate ...>
Logon : <bean:write  name="user" property="logon"/>
Position: <ma:droplist name="user" property="position" 

The droplist tag will produce the following with
Logon : Jack     Position:  Director
Logon : Jill         Position: Manager
Logon : Charlie  Position: Manager

I am happy to contribute this back the STRUTS tag lib or if anyone is 
interested, let me know and I will send you the code. This functionality 
consists of


To add the functionality to your JSP you will need to

1) Add the tld to your web.xml.
2) Add the tld to your JSP.

This tag also works with indexed beans as is extended 


Michael Mok

MAD ART | Lead Technical Architect
m| 0417 968 581

This e-mail is the property of MadArt Services and/or its relevant affiliate and may contain
confidential and privileged material for the sole use of the intended recipient(s). Any review,
use, distribution or disclosure by others is strictly prohibited. If you are not the intended
recipient (or authorized to receive for the recipient), please contact the sender and delete
all copies of the message. This e-mail (and any attachments hereto) are not intended to be
an offer (or an acceptance) and do not create or evidence a binding and enforceable contract
between MadArt Services (or any of its affiliates) and the intended recipient or any other
party, and may not be relied on by anyone as the basis of a contract by estoppel or otherwise.
Thank you.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message