struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From R Balaji <>
Subject Re: Possible to dynamically set value of an <html:select> element?
Date Sun, 27 Jul 2003 10:13:22 GMT

Have you ever tried with heml-el:select, where you can pass such 
expresions .

David Benoff wrote:

>Pardon the newbie-ness but I’ve searched the archives extensively and
>haven’t turned up anything on this.  Any hints would be much
>I’d like to know whether there is any way to dynamically set the
>property attribute within an html:select element.  
>The page I’m working on iterates through a collection of User beans,
>each of which has its own collection of Role beans.  Each user is
>displayed on a row with a dropdown that is populated with that user’s
>collection of roles.  The user needs to select a single Role for each
>user displayed, and I’d like to get the form returned as a HashMap with
>the username as the key and the rolename as the value.
>The relevant snippet is below:
><logic:iterate id="user" name="userlist">
><bean:write name="user" property="username"/>
><html:select property="rolemap(username)">
><html:optionsCollection name="user" property="roles" value="rolename"/>
>My problem, of course, is that since property="rolemap(username)” isn’t
>dynamic, the key gets stored verbosely as “username”, which overwrites
>the value on each iteration, so the map always gets returned with a
>single value.
>My guess is there’s a straightforward way to do this, but I’ll be darned
>if I can find it.  I’d very much appreciate it if someone could point me
>in the right direction.
>David Benoff
>Outgoing mail is certified Virus Free.
>Checked by AVG anti-virus system (
>Version: 6.0.502 / Virus Database: 300 - Release Date: 7/18/2003

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message