struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sudipta Sarkar" <>
Subject Re: How do I pre-select an element from a select list?
Date Thu, 21 Mar 2002 22:47:42 GMT
Step 1.
  In JSP
  <html:select property="choice" value="2" >
       <html:options labelProperty="labels" property="values"/>

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

  public Collection getLabels()
		ArrayList a = new ArrayList();
		return a;

	public Collection getValues()
		ArrayList a = new ArrayList();
		return a;

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


>From: Struts Newsgroup ( <>
>Reply-To: "Struts Users Mailing List" <>
>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" <>
>  ===
>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 
>to be able to have the form displayed with "Second" already selected.  
>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 
>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 
>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:   
>For additional commands, e-mail: 

Chat with friends online, try MSN Messenger:

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

View raw message