You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Spencer Smith <sp...@newdestiny.net> on 2001/03/01 17:39:01 UTC

Re: Drop-down list

This is how we do it...(I think the work simple should be ommitted)

Get the content at the top of the JSP page.
<%
pageContext.setAttribute("nameSuffixTypes", getServletContext().getAttribute("nameSuffixTypes"));
%>

Place this where you want the Drop Down List on the JSP page.
<html:select property="suffix"> 
       <html:options collection="nameSuffixTypes" property="value" labelProperty="label" /> 
</html:select>  
  ----- Original Message ----- 
  From: Kyle Robinson 
  To: 'struts-user@jakarta.apache.org' 
  Sent: Thursday, March 01, 2001 8:42 AM
  Subject: Drop-down list


  What is the simplest way to dynamically create a drop-down list (<select>) that pulls values from a database?  Is there a specific tag I should use?  Iterator?
  Kyle Robinson 
  Systems Consultant 
  Pangaea Systems Inc. 
  (250) 360-0111 



Re: Drop-down list

Posted by Spencer Smith <sp...@newdestiny.net>.
Provide Name(s)&nbsp;
<html:select property="providerName" multiple="true" size="2">
    <html:options collection="cmProviderTypes" property="value"
labelProperty="label" />
</html:select>

Like this, correct?


----- Original Message -----
From: "Spencer Smith" <sp...@newdestiny.net>
To: <st...@jakarta.apache.org>
Sent: Thursday, March 01, 2001 1:02 PM
Subject: Re: Drop-down list


>
> Trying to use Multiple="true" attribute for html:select
>
> Help!
>
> O.k. so I declare it like so:
>  protected String[] providerName;
>
> Then I get it:
>  public String[] getProviderName()
>  {
>   return (providerName);
>  }
>
> Then I set it:
>  public void setProviderName(String providerName[]) {
>   { this.providerName = providerName; }
>   }
>
>
> What am I missing?
>
>
> ----- Original Message -----
> From: <ma...@tumbleweed.com>
> To: <st...@jakarta.apache.org>
> Sent: Thursday, March 01, 2001 12:02 PM
> Subject: Re: Drop-down list
>
>
> > Add the attribute to your tag like so:
> >
> > <html:select ... multiple="true" ...>
> >
> > and make sure the corresponding property in your form bean is an array
of
> > values.
> >
> > See the docs for more details:
> >
> > http://jakarta.apache.org/struts/struts-html.html#select
> >
> > Hope this helps.
> >
> > --
> > Martin Cooper
> > Tumbleweed Communications
> >
> >
> > At 11:44 AM 3/1/01 -0800, Spencer Smith wrote:
> > >Do you guys know how to define the Multiple attribute in a select drop
> down
> > >list for Struts?
> > >
> > >----- Original Message -----
> > >From: "Peter Alfors" <pe...@irista.com>
> > >To: <st...@jakarta.apache.org>
> > >Sent: Thursday, March 01, 2001 11:29 AM
> > >Subject: Re: Drop-down list
> > >
> > >
> > > > When adding options to a select that are stored in a database, we
have
> the
> > > > action class look-up the necessary information, store it in a bean,
> place
> > >the
> > > > bean in the request / session, and then use a taglib on the page
that
> > >specifies
> > > > the source (the bean) and the property (database column) that should
> be
> > >used to
> > > > populate the select.
> > > > This gaurentees that the data in the select list is up to date.
> > > >
> > > > HTH,
> > > >     Pete
> > > >
> > > > "Deadman, Hal" wrote:
> > > >
> > > > > Does this assume that you have loaded a Collection of
> LabelValueBeans in
> > >the
> > > > > application scope? Do you really need that scriplet at the top of
> the
> > >page?
> > > > > I thought html:options could reference the collection where it is
in
> the
> > > > > servlet context, without copying the reference to the page
context.
> > > > >
> > > > > Hal
> > > > >
> > > > > -----Original Message-----
> > > > > From: Spencer Smith [mailto:spencers@newdestiny.net]
> > > > > Sent: Thursday, March 01, 2001 11:39 AM
> > > > > To: struts-user@jakarta.apache.org
> > > > > Subject: Re: Drop-down list
> > > > >
> > > > > This is how we do it...(I think the work simple should be
ommitted)
> > > > >
> > > > > Get the content at the top of the JSP page.
> > > > > <%
> > > > > pageContext.setAttribute("nameSuffixTypes",
> > > > > getServletContext().getAttribute("nameSuffixTypes"));
> > > > > %>
> > > > >
> > > > > Place this where you want the Drop Down List on the JSP page.
> > > > > <html:select property="suffix">
> > > > >        <html:options collection="nameSuffixTypes" property="value"
> > > > > labelProperty="label" />
> > > > > </html:select>
> > > > >
> > > > > ----- Original Message -----
> > > > > From: Kyle  <ma...@pangaeainc.com> Robinson
> > > > > To: 'struts-user@jakarta.apache.org'
> > > > > <mailto:'struts-user@jakarta.apache.org'>
> > > > > Sent: Thursday, March 01, 2001 8:42 AM
> > > > > Subject: Drop-down list
> > > > >
> > > > > What is the simplest way to dynamically create a drop-down list
> > > > > (<select>) that pulls values from a database?  Is there a specific
> tag I
> > > > > should use?  Iterator?
> > > > >
> > > > > Kyle Robinson
> > > > > Systems Consultant
> > > > > Pangaea Systems Inc.
> > > > > (250) 360-0111
> > > >
> >
> >
> >
>
>


Re: Drop-down list

Posted by Spencer Smith <sp...@newdestiny.net>.
Trying to use Multiple="true" attribute for html:select

Help!

O.k. so I declare it like so:
 protected String[] providerName;

Then I get it:
 public String[] getProviderName()
 {
  return (providerName);
 }

Then I set it:
 public void setProviderName(String providerName[]) {
  { this.providerName = providerName; }
  }


What am I missing?


----- Original Message -----
From: <ma...@tumbleweed.com>
To: <st...@jakarta.apache.org>
Sent: Thursday, March 01, 2001 12:02 PM
Subject: Re: Drop-down list


> Add the attribute to your tag like so:
>
> <html:select ... multiple="true" ...>
>
> and make sure the corresponding property in your form bean is an array of
> values.
>
> See the docs for more details:
>
> http://jakarta.apache.org/struts/struts-html.html#select
>
> Hope this helps.
>
> --
> Martin Cooper
> Tumbleweed Communications
>
>
> At 11:44 AM 3/1/01 -0800, Spencer Smith wrote:
> >Do you guys know how to define the Multiple attribute in a select drop
down
> >list for Struts?
> >
> >----- Original Message -----
> >From: "Peter Alfors" <pe...@irista.com>
> >To: <st...@jakarta.apache.org>
> >Sent: Thursday, March 01, 2001 11:29 AM
> >Subject: Re: Drop-down list
> >
> >
> > > When adding options to a select that are stored in a database, we have
the
> > > action class look-up the necessary information, store it in a bean,
place
> >the
> > > bean in the request / session, and then use a taglib on the page that
> >specifies
> > > the source (the bean) and the property (database column) that should
be
> >used to
> > > populate the select.
> > > This gaurentees that the data in the select list is up to date.
> > >
> > > HTH,
> > >     Pete
> > >
> > > "Deadman, Hal" wrote:
> > >
> > > > Does this assume that you have loaded a Collection of
LabelValueBeans in
> >the
> > > > application scope? Do you really need that scriplet at the top of
the
> >page?
> > > > I thought html:options could reference the collection where it is in
the
> > > > servlet context, without copying the reference to the page context.
> > > >
> > > > Hal
> > > >
> > > > -----Original Message-----
> > > > From: Spencer Smith [mailto:spencers@newdestiny.net]
> > > > Sent: Thursday, March 01, 2001 11:39 AM
> > > > To: struts-user@jakarta.apache.org
> > > > Subject: Re: Drop-down list
> > > >
> > > > This is how we do it...(I think the work simple should be ommitted)
> > > >
> > > > Get the content at the top of the JSP page.
> > > > <%
> > > > pageContext.setAttribute("nameSuffixTypes",
> > > > getServletContext().getAttribute("nameSuffixTypes"));
> > > > %>
> > > >
> > > > Place this where you want the Drop Down List on the JSP page.
> > > > <html:select property="suffix">
> > > >        <html:options collection="nameSuffixTypes" property="value"
> > > > labelProperty="label" />
> > > > </html:select>
> > > >
> > > > ----- Original Message -----
> > > > From: Kyle  <ma...@pangaeainc.com> Robinson
> > > > To: 'struts-user@jakarta.apache.org'
> > > > <mailto:'struts-user@jakarta.apache.org'>
> > > > Sent: Thursday, March 01, 2001 8:42 AM
> > > > Subject: Drop-down list
> > > >
> > > > What is the simplest way to dynamically create a drop-down list
> > > > (<select>) that pulls values from a database?  Is there a specific
tag I
> > > > should use?  Iterator?
> > > >
> > > > Kyle Robinson
> > > > Systems Consultant
> > > > Pangaea Systems Inc.
> > > > (250) 360-0111
> > >
>
>
>


Re: Drop-down list

Posted by ma...@tumbleweed.com.
Add the attribute to your tag like so:

<html:select ... multiple="true" ...>

and make sure the corresponding property in your form bean is an array of 
values.

See the docs for more details:

http://jakarta.apache.org/struts/struts-html.html#select

Hope this helps.

--
Martin Cooper
Tumbleweed Communications


At 11:44 AM 3/1/01 -0800, Spencer Smith wrote:
>Do you guys know how to define the Multiple attribute in a select drop down
>list for Struts?
>
>----- Original Message -----
>From: "Peter Alfors" <pe...@irista.com>
>To: <st...@jakarta.apache.org>
>Sent: Thursday, March 01, 2001 11:29 AM
>Subject: Re: Drop-down list
>
>
> > When adding options to a select that are stored in a database, we have the
> > action class look-up the necessary information, store it in a bean, place
>the
> > bean in the request / session, and then use a taglib on the page that
>specifies
> > the source (the bean) and the property (database column) that should be
>used to
> > populate the select.
> > This gaurentees that the data in the select list is up to date.
> >
> > HTH,
> >     Pete
> >
> > "Deadman, Hal" wrote:
> >
> > > Does this assume that you have loaded a Collection of LabelValueBeans in
>the
> > > application scope? Do you really need that scriplet at the top of the
>page?
> > > I thought html:options could reference the collection where it is in the
> > > servlet context, without copying the reference to the page context.
> > >
> > > Hal
> > >
> > > -----Original Message-----
> > > From: Spencer Smith [mailto:spencers@newdestiny.net]
> > > Sent: Thursday, March 01, 2001 11:39 AM
> > > To: struts-user@jakarta.apache.org
> > > Subject: Re: Drop-down list
> > >
> > > This is how we do it...(I think the work simple should be ommitted)
> > >
> > > Get the content at the top of the JSP page.
> > > <%
> > > pageContext.setAttribute("nameSuffixTypes",
> > > getServletContext().getAttribute("nameSuffixTypes"));
> > > %>
> > >
> > > Place this where you want the Drop Down List on the JSP page.
> > > <html:select property="suffix">
> > >        <html:options collection="nameSuffixTypes" property="value"
> > > labelProperty="label" />
> > > </html:select>
> > >
> > > ----- Original Message -----
> > > From: Kyle  <ma...@pangaeainc.com> Robinson
> > > To: 'struts-user@jakarta.apache.org'
> > > <mailto:'struts-user@jakarta.apache.org'>
> > > Sent: Thursday, March 01, 2001 8:42 AM
> > > Subject: Drop-down list
> > >
> > > What is the simplest way to dynamically create a drop-down list
> > > (<select>) that pulls values from a database?  Is there a specific tag I
> > > should use?  Iterator?
> > >
> > > Kyle Robinson
> > > Systems Consultant
> > > Pangaea Systems Inc.
> > > (250) 360-0111
> >



Re: Drop-down list

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Spencer Smith wrote:

> Do you guys know how to define the Multiple attribute in a select drop down
> list for Struts?
>

<select name="propertyname" multiple="true">

In XML syntax, attributes always have to have a value.

Craig



Re: Drop-down list

Posted by Spencer Smith <sp...@newdestiny.net>.
Do you guys know how to define the Multiple attribute in a select drop down
list for Struts?

----- Original Message -----
From: "Peter Alfors" <pe...@irista.com>
To: <st...@jakarta.apache.org>
Sent: Thursday, March 01, 2001 11:29 AM
Subject: Re: Drop-down list


> When adding options to a select that are stored in a database, we have the
> action class look-up the necessary information, store it in a bean, place
the
> bean in the request / session, and then use a taglib on the page that
specifies
> the source (the bean) and the property (database column) that should be
used to
> populate the select.
> This gaurentees that the data in the select list is up to date.
>
> HTH,
>     Pete
>
> "Deadman, Hal" wrote:
>
> > Does this assume that you have loaded a Collection of LabelValueBeans in
the
> > application scope? Do you really need that scriplet at the top of the
page?
> > I thought html:options could reference the collection where it is in the
> > servlet context, without copying the reference to the page context.
> >
> > Hal
> >
> > -----Original Message-----
> > From: Spencer Smith [mailto:spencers@newdestiny.net]
> > Sent: Thursday, March 01, 2001 11:39 AM
> > To: struts-user@jakarta.apache.org
> > Subject: Re: Drop-down list
> >
> > This is how we do it...(I think the work simple should be ommitted)
> >
> > Get the content at the top of the JSP page.
> > <%
> > pageContext.setAttribute("nameSuffixTypes",
> > getServletContext().getAttribute("nameSuffixTypes"));
> > %>
> >
> > Place this where you want the Drop Down List on the JSP page.
> > <html:select property="suffix">
> >        <html:options collection="nameSuffixTypes" property="value"
> > labelProperty="label" />
> > </html:select>
> >
> > ----- Original Message -----
> > From: Kyle  <ma...@pangaeainc.com> Robinson
> > To: 'struts-user@jakarta.apache.org'
> > <mailto:'struts-user@jakarta.apache.org'>
> > Sent: Thursday, March 01, 2001 8:42 AM
> > Subject: Drop-down list
> >
> > What is the simplest way to dynamically create a drop-down list
> > (<select>) that pulls values from a database?  Is there a specific tag I
> > should use?  Iterator?
> >
> > Kyle Robinson
> > Systems Consultant
> > Pangaea Systems Inc.
> > (250) 360-0111
>


Re: Drop-down list

Posted by Peter Alfors <pe...@irista.com>.
When adding options to a select that are stored in a database, we have the
action class look-up the necessary information, store it in a bean, place the
bean in the request / session, and then use a taglib on the page that specifies
the source (the bean) and the property (database column) that should be used to
populate the select.
This gaurentees that the data in the select list is up to date.

HTH,
    Pete

"Deadman, Hal" wrote:

> Does this assume that you have loaded a Collection of LabelValueBeans in the
> application scope? Do you really need that scriplet at the top of the page?
> I thought html:options could reference the collection where it is in the
> servlet context, without copying the reference to the page context.
>
> Hal
>
> -----Original Message-----
> From: Spencer Smith [mailto:spencers@newdestiny.net]
> Sent: Thursday, March 01, 2001 11:39 AM
> To: struts-user@jakarta.apache.org
> Subject: Re: Drop-down list
>
> This is how we do it...(I think the work simple should be ommitted)
>
> Get the content at the top of the JSP page.
> <%
> pageContext.setAttribute("nameSuffixTypes",
> getServletContext().getAttribute("nameSuffixTypes"));
> %>
>
> Place this where you want the Drop Down List on the JSP page.
> <html:select property="suffix">
>        <html:options collection="nameSuffixTypes" property="value"
> labelProperty="label" />
> </html:select>
>
> ----- Original Message -----
> From: Kyle  <ma...@pangaeainc.com> Robinson
> To: 'struts-user@jakarta.apache.org'
> <mailto:'struts-user@jakarta.apache.org'>
> Sent: Thursday, March 01, 2001 8:42 AM
> Subject: Drop-down list
>
> What is the simplest way to dynamically create a drop-down list
> (<select>) that pulls values from a database?  Is there a specific tag I
> should use?  Iterator?
>
> Kyle Robinson
> Systems Consultant
> Pangaea Systems Inc.
> (250) 360-0111

RE: Drop-down list

Posted by "Deadman, Hal" <ha...@tallan.com>.
Does this assume that you have loaded a Collection of LabelValueBeans in the
application scope? Do you really need that scriplet at the top of the page?
I thought html:options could reference the collection where it is in the
servlet context, without copying the reference to the page context.

Hal

-----Original Message-----
From: Spencer Smith [mailto:spencers@newdestiny.net]
Sent: Thursday, March 01, 2001 11:39 AM
To: struts-user@jakarta.apache.org
Subject: Re: Drop-down list


This is how we do it...(I think the work simple should be ommitted)

Get the content at the top of the JSP page.
<%
pageContext.setAttribute("nameSuffixTypes",
getServletContext().getAttribute("nameSuffixTypes"));
%>

Place this where you want the Drop Down List on the JSP page.
<html:select property="suffix">
       <html:options collection="nameSuffixTypes" property="value"
labelProperty="label" />
</html:select>

----- Original Message -----
From: Kyle  <ma...@pangaeainc.com> Robinson
To: 'struts-user@jakarta.apache.org'
<mailto:'struts-user@jakarta.apache.org'>
Sent: Thursday, March 01, 2001 8:42 AM
Subject: Drop-down list

What is the simplest way to dynamically create a drop-down list
(<select>) that pulls values from a database?  Is there a specific tag I
should use?  Iterator?

Kyle Robinson
Systems Consultant
Pangaea Systems Inc.
(250) 360-0111