You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by David Benoff <db...@covad.net> on 2003/07/27 09:46:00 UTC

Possible to dynamically set value of an element?

Pardon the newbie-ness but I’ve searched the archives extensively and
haven’t turned up anything on this.  Any hints would be much
appreciated.
 
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"/>
</html:select>
 
</logic:iterate>
 
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.
 
Thanks,
David Benoff
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.502 / Virus Database: 300 - Release Date: 7/18/2003
 

RE: Possible to dynamically set value of an element?

Posted by David Benoff <db...@covad.net>.
Thanks balaji, I'll try that:)

David

-----Original Message-----
From: R Balaji [mailto:balajir@india.adventnet.com] 
Sent: Sunday, July 27, 2003 3:13 AM
To: Struts Users Mailing List
Subject: Re: Possible to dynamically set value of an <html:select>
element?


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

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
>appreciated.
> 
>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"/>
></html:select>
> 
></logic:iterate>
> 
>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.
> 
>Thanks,
>David Benoff
> 
>
>---
>Outgoing mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.502 / Virus Database: 300 - Release Date: 7/18/2003
> 
>
>  
>

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.502 / Virus Database: 300 - Release Date: 7/18/2003
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.502 / Virus Database: 300 - Release Date: 7/18/2003
 


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Possible to dynamically set value of an element?

Posted by R Balaji <ba...@india.adventnet.com>.
Have you ever tried with heml-el:select, where you can pass such 
expresions .
balaji

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
>appreciated.
> 
>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"/>
></html:select>
> 
></logic:iterate>
> 
>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.
> 
>Thanks,
>David Benoff
> 
>
>---
>Outgoing mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.502 / Virus Database: 300 - Release Date: 7/18/2003
> 
>
>  
>