You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Anthony Martin <An...@TRAMS.com> on 2001/04/12 04:04:56 UTC

I can't figure out the struts way to do this:

       <html:select property="staffId">
        <logic:iterate id="staffId" name="breakForm" property="staffIds"
scope="request">
         <OPTION value="<bean:write name="staffId" property="key"
/>"><bean:write name="staffId" property="value" /></OPTION>
        </logic:iterate>
       </html:select>

The staffIds bean property is a hashtable.  I wanted to use <html:option> or
even <html:options> but the syntax eludes me.  I can change the hashtable to
some type of collection, but this way the screen looks right.  The
functionality of repopulate is missing, though because I'm not allowing
struts to render the <OPTION>.  Any ideas?


Anthony

It is by caffeine alone I set my mind in motion.
It is by the Beans of Java that thoughts acquire speed,
the hands acquire shaking, the shaking becomes a warning.
It is by caffeine alone I set my mind in motion.

Re:

Posted by Johan Compagner <jc...@j-com.nl>.
Now i think of it is it possible to supply only a hashmap to <html:options>
and that the key's are the property (the keys) and the value the labels?

now i always have 3 methods to fill in a combo:

getXxxxId
getXxxxIds
getXxxxLabels

johan

----- Original Message -----
From: "Jim Crossley" <ji...@lads.com>
To: <st...@jakarta.apache.org>
Sent: Thursday, April 12, 2001 7:03 AM
Subject: Re: <html:option>


> If you change staffIds to a Collection, i.e. staffIds.entrySet(), I
> *think* this will work:
>
> <% Set set = staffIds.entrySet(); %>
> <html:select property="staffId">
>   <html:options collection="set" property="key" labelProperty="value"/>
> </html:select>
>
> Anthony Martin wrote:
> >
> > I can't figure out the struts way to do this:
> >
> >        <html:select property="staffId">
> >         <logic:iterate id="staffId" name="breakForm" property="staffIds"
> > scope="request">
> >          <OPTION value="<bean:write name="staffId" property="key"
> > />"><bean:write name="staffId" property="value" /></OPTION>
> >         </logic:iterate>
> >        </html:select>
> >
> > The staffIds bean property is a hashtable.  I wanted to use
<html:option> or
> > even <html:options> but the syntax eludes me.  I can change the
hashtable to
> > some type of collection, but this way the screen looks right.  The
> > functionality of repopulate is missing, though because I'm not allowing
> > struts to render the <OPTION>.  Any ideas?
> >
> > Anthony
> >
> > It is by caffeine alone I set my mind in motion.
> > It is by the Beans of Java that thoughts acquire speed,
> > the hands acquire shaking, the shaking becomes a warning.
> > It is by caffeine alone I set my mind in motion.
>


Re:

Posted by Jim Crossley <ji...@lads.com>.
If you change staffIds to a Collection, i.e. staffIds.entrySet(), I
*think* this will work:

<% Set set = staffIds.entrySet(); %>
<html:select property="staffId">
  <html:options collection="set" property="key" labelProperty="value"/>
</html:select>

Anthony Martin wrote:
> 
> I can't figure out the struts way to do this:
> 
>        <html:select property="staffId">
>         <logic:iterate id="staffId" name="breakForm" property="staffIds"
> scope="request">
>          <OPTION value="<bean:write name="staffId" property="key"
> />"><bean:write name="staffId" property="value" /></OPTION>
>         </logic:iterate>
>        </html:select>
> 
> The staffIds bean property is a hashtable.  I wanted to use <html:option> or
> even <html:options> but the syntax eludes me.  I can change the hashtable to
> some type of collection, but this way the screen looks right.  The
> functionality of repopulate is missing, though because I'm not allowing
> struts to render the <OPTION>.  Any ideas?
> 
> Anthony
> 
> It is by caffeine alone I set my mind in motion.
> It is by the Beans of Java that thoughts acquire speed,
> the hands acquire shaking, the shaking becomes a warning.
> It is by caffeine alone I set my mind in motion.