Paul:
I tried the following in the JSP based on your suggestion and it is still
not defaulting to the desired option.   I just want to default the option to
whatever matches between "shopWorkOrder.engineerId" and "userId".

Segment of JSP:
      <bean:define id="eList" name="ShopWorkOrderFormBean"
property="engineerList"/>
      <html:select property="shopWorkOrder.engineerId">
       <html:options collection="eList" name="ShopWorkOrderFormBean"
property="userId" labelproperty="commonName"/>
      </html:select>


The following debug section is used to print out if
"shopWorkOrder.engineerId" matches any "userId" in the ArrayList:

String engineer =  formBean.getShopWorkOrder().getEngineerId();
PeopleBean pBean;
EtLog.debug(this,"EngineerId="+engineer+"***");
for (int i=0; i<formBean.getEngineerList().size(); i++) {
   pBean = (PeopleBean) formBean.getEngineerList().get(i);
   if (engineer != null && engineer.equals(pBean.getUserId())) {
       EtLog.debug(this,"Found Matching ID=" + pBean.getUserId() + "***");
       break;
   }
}

And the debug printout suggested it found a matching id.   But the
<html:select> and <html:option> won't default to it:
03/09/2004 10:54:28 [DBUG] ShopWorkOrderMaintainAction  EngineerId=8***
03/09/2004 10:54:28 [DBUG] ShopWorkOrderMaintainAction  Found Matching
ID=8***


Did I misunderstand what you suggested?


-----Original Message-----
From: Paul Stanton [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, March 09, 2004 12:45 AM
To: Au-Yeung, Stella H
Subject: <html:select>


this is by far the simplest way to achieve what you desire, but it does 
assume that your form is already populated with data. if your form is 
populated, the populated values will be used to select the correct 
option in the <select>. if it isn't (or the field is null) no <option> 
will be selected. i like to set my defaults to the fields values on the 
form bean in "reset()" and at field initialisation.

<html:select property="formBeanProp">
        <html:options collection="collection" property="listProp" 
labelProperty="listLabel" />
</html:select>

formBeanProp:
the name of the field on the form bean of the enclosing <html:form> tag. 
if this field has a value matching one of the "listProp" values, this 
item will be selected.

collection:
the name of the attribute you have stored the list you are using to 
populate the options under.

listProp:
the name of the field in the list elements that will be used to compare 
to the "formBeanProp".

listLabel:
the name of the field in the list elements that will be displayed to the 
user. note: if your value/label for your options is going to be the same 
you can omit this.

hope this helps.

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

Reply via email to