Re: How do I pre-select an element from a select list?

2002-03-21 Thread Jim Crossley

Remove the value attribute from the html:select tag.  In your action's
perform method, call formbean.setChoice("2") prior to forwarding the
request to your jsp.

Struts Newsgroup (@Basebeans.com) <[EMAIL PROTECTED]> writes:

> Subject: Re: How do I pre-select an element from a select list?
> From: "Scott Danzig" <[EMAIL PROTECTED]>
>  ===
> This helps a lot... it was very clear.  I'm stuck on one more thing.  I need
> to dynamically set the preselected value from the Action class.  I tried
> adding a property to the form:
> 
>  
>   
>  
> 
> .. I then set in the form for selectedCurrentLocation to be a string that
> was one of the values of an option, checking the source to compare for sure.
> It doesn't work  The source shows that the parameter value="something" for
> the select tag doesn't even show up.  When I replace it with a hard-coded
> value="2", for instance, it does work, however.  If you or someone else
> could help, it'd be very much appreciated.  If more information is needed,
> lemme know.  Thanks.
> 
> Scott Danzig
> [EMAIL PROTECTED]
> 
> "Sudipta Sarkar" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]...
> > Step 1.
> >   In JSP
> >   
> >
> >   
> >
> > Step 2.
> >   the formbean has methods getLabels and getValues()
> >
> >   public Collection getLabels()
> > {
> > ArrayList a = new ArrayList();
> > a.add("One");
> > a.add("Two");
> > a.add("Three");
> > return a;
> > }
> >
> > public Collection getValues()
> > {
> > ArrayList a = new ArrayList();
> > a.add("1");
> > a.add("2");
> > a.add("3");
> > return a;
> > }
> >
> > Step 3.
> >   Notice the value attribute of  .This is the value to
> compare
> > with for marking an option selected. Since I have specified value="2" so
> > option "Two" will be selected.
> >
> > Thanks
> > Sudipta
> >
> > >From: Struts Newsgroup (@Basebeans.com) <[EMAIL PROTECTED]>
> > >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> > >To: [EMAIL PROTECTED]
> > >Subject: How do I pre-select an element from a select list?
> > >Date: Thu, 21 Mar 2002 13:55:02 -0800
> > >
> > >Subject: How do I pre-select an element from a select list?
> > >From: "Scott Danzig" <[EMAIL PROTECTED]>
> > >  ===
> > >Hi,
> > >
> > >Using Struts, I'm able to create an instance of a form, and prepopulate
> it
> > >with various information, then have it display this information in HTML
> > >spawned from a JSP page after the forward("success").  I'm unable,
> however,
> > >to figure out how to pre-select an element from a select list.  Like if a
> > >dropdown html SELECT menu displayed "First", "Second", and "Third", I'd
> > >want
> > >to be able to have the form displayed with "Second" already selected.
> > >Given
> > >I'm rather new to struts, let alone EJB and servlets, could someone
> please
> > >explain very clearly about how to do the three steps involved with this?
> > >First, adding the get/set functions to the form class.. what arguments
> > >would
> > >they take?  Second, how to add the html:select and html:options tags to
> the
> > >JSP page so that I can prefill them with this form class, and lastly, in
> > >the
> > >Action class which I have querying another datasource and retrieving this
> > >information, setting the necessary things in the form class, what
> > >property/attribute do I set in this form object, to have it preselect an
> > >element in the select list?  Thanks.
> > >Scott Danzig
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

-- 
Jim Crossley
http://www.lads.com/~jim

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: How do I pre-select an element from a select list?

2002-03-21 Thread @Basebeans.com

Subject: Re: How do I pre-select an element from a select list?
From: "Scott Danzig" <[EMAIL PROTECTED]>
 ===
This helps a lot... it was very clear.  I'm stuck on one more thing.  I need
to dynamically set the preselected value from the Action class.  I tried
adding a property to the form:

 
  
 

.. I then set in the form for selectedCurrentLocation to be a string that
was one of the values of an option, checking the source to compare for sure.
It doesn't work  The source shows that the parameter value="something" for
the select tag doesn't even show up.  When I replace it with a hard-coded
value="2", for instance, it does work, however.  If you or someone else
could help, it'd be very much appreciated.  If more information is needed,
lemme know.  Thanks.

Scott Danzig
[EMAIL PROTECTED]

"Sudipta Sarkar" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]...
> Step 1.
>   In JSP
>   
>
>   
>
> Step 2.
>   the formbean has methods getLabels and getValues()
>
>   public Collection getLabels()
> {
> ArrayList a = new ArrayList();
> a.add("One");
> a.add("Two");
> a.add("Three");
> return a;
> }
>
> public Collection getValues()
> {
> ArrayList a = new ArrayList();
> a.add("1");
> a.add("2");
> a.add("3");
> return a;
> }
>
> Step 3.
>   Notice the value attribute of  .This is the value to
compare
> with for marking an option selected. Since I have specified value="2" so
> option "Two" will be selected.
>
> Thanks
> Sudipta
>
> >From: Struts Newsgroup (@Basebeans.com) <[EMAIL PROTECTED]>
> >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> >To: [EMAIL PROTECTED]
> >Subject: How do I pre-select an element from a select list?
> >Date: Thu, 21 Mar 2002 13:55:02 -0800
> >
> >Subject: How do I pre-select an element from a select list?
> >From: "Scott Danzig" <[EMAIL PROTECTED]>
> >  ===
> >Hi,
> >
> >Using Struts, I'm able to create an instance of a form, and prepopulate
it
> >with various information, then have it display this information in HTML
> >spawned from a JSP page after the forward("success").  I'm unable,
however,
> >to figure out how to pre-select an element from a select list.  Like if a
> >dropdown html SELECT menu displayed "First", "Second", and "Third", I'd
> >want
> >to be able to have the form displayed with "Second" already selected.
> >Given
> >I'm rather new to struts, let alone EJB and servlets, could someone
please
> >explain very clearly about how to do the three steps involved with this?
> >First, adding the get/set functions to the form class.. what arguments
> >would
> >they take?  Second, how to add the html:select and html:options tags to
the
> >JSP page so that I can prefill them with this form class, and lastly, in
> >the
> >Action class which I have querying another datasource and retrieving this
> >information, setting the necessary things in the form class, what
> >property/attribute do I set in this form object, to have it preselect an
> >element in the select list?  Thanks.
> >Scott Danzig




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: How do I pre-select an element from a select list?

2002-03-21 Thread Sudipta Sarkar

Step 1.
  In JSP
  
   
  

Step 2.
  the formbean has methods getLabels and getValues()

  public Collection getLabels()
{
ArrayList a = new ArrayList();
a.add("One");
a.add("Two");
a.add("Three");
return a;
}

public Collection getValues()
{
ArrayList a = new ArrayList();
a.add("1");
a.add("2");
a.add("3");
return a;
}

Step 3.
  Notice the value attribute of  .This is the value to compare 
with for marking an option selected. Since I have specified value="2" so 
option "Two" will be selected.

Thanks
Sudipta

>From: Struts Newsgroup (@Basebeans.com) <[EMAIL PROTECTED]>
>Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: How do I pre-select an element from a select list?
>Date: Thu, 21 Mar 2002 13:55:02 -0800
>
>Subject: How do I pre-select an element from a select list?
>From: "Scott Danzig" <[EMAIL PROTECTED]>
>  ===
>Hi,
>
>Using Struts, I'm able to create an instance of a form, and prepopulate it
>with various information, then have it display this information in HTML
>spawned from a JSP page after the forward("success").  I'm unable, however,
>to figure out how to pre-select an element from a select list.  Like if a
>dropdown html SELECT menu displayed "First", "Second", and "Third", I'd 
>want
>to be able to have the form displayed with "Second" already selected.  
>Given
>I'm rather new to struts, let alone EJB and servlets, could someone please
>explain very clearly about how to do the three steps involved with this?
>First, adding the get/set functions to the form class.. what arguments 
>would
>they take?  Second, how to add the html:select and html:options tags to the
>JSP page so that I can prefill them with this form class, and lastly, in 
>the
>Action class which I have querying another datasource and retrieving this
>information, setting the necessary things in the form class, what
>property/attribute do I set in this form object, to have it preselect an
>element in the select list?  Thanks.
>
>Scott Danzig
>[EMAIL PROTECTED]
>
>
>
>--
>To unsubscribe, e-mail:   
>
>For additional commands, e-mail: 
>
>




_
Chat with friends online, try MSN Messenger: http://messenger.msn.com


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