Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

try try again

Status
Not open for further replies.

jcamp

Programmer
Mar 31, 2004
31
US
i'm rather desperate to get an answer to this question.

i'm going on memory since the web app i'm working on is at work and not home.

i have a bean named 'SITE' which has a property 'siteDesc'
which returns a string.

i have the following select options logic:

<html:select name="SITE" property="siteDesc">
<html:eek:ptions name="SITE" property="siteDesc"/>
</html:select>

this gives me the drop down list i desire, but i don't know how to make the list 'select' a particular value when expressed to the jsp.

can someone please help me out?!
 
Hi,

Can you paste the src code here that will help.

Here is the try I am giving.

Site bean has to properites 1. siteName and 2. siteDesc
populating arrayList of Site beans and set it in pageContext and the value that it has to select is "site1".

The below code should select "desc3";

Code:
<%
  ArrayList site = new ArrayList();
  for(int i=0;i<10;i++)
  {
    site.add(new Site("name"+i,"desc"+i));
  }
  pageContext.add("site",site);
  pageContext.add("site1","desc3");
%>

<html:select property="site1">
 <html:options collection="site" property="siteDesc"					labelProperty="siteName" />
</html:select>


Cheers
Venu
 
if the pre-select value is fixed, you can initialize it in your form-property using the 'initial' attribute. struts-html automatically populate your form with initial values if defined.

if the pre-select comes from the backend, you need to do a form.set("myFormField", preselectValue); inside you Action.execute(), where from is the local variable referring to your ActionForm mapped to your action.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top