Thanks Niall. That's it. Puttingthe 'attrbute' in <html:select> solve my problem. Thanks.
-----Original Message----- From: Niall Pemberton [mailto:[EMAIL PROTECTED] Sent: Friday, March 12, 2004 10:54 AM To: Struts Users Mailing List Subject: Re: Someone out there must have done this with Struts 1.0 The <html:optionsCollection> tag was introduced in Struts 1.1 so thats why it doesn't work - which means you are correct to use the <html:options> tag. The only comment I have, the difference between your debug stuff and the <html:select> tag is you missed out the "name" attribute on the <html:select> tag . Also, on the <html:options> tag if you use the "collection" attribute then the "name" attribute is not used - its not an issue, but you just don't need it. Try <bean:define id="eList" name="ShopWorkOrderFormBean" property="engineerList"/> <html:select name="ShopWorkOrderFormBean" property="shopWorkOrder.engineerId" > <html:options collection="eList" property="userId" labelProperty="commonName"/> </html:select> Niall ----- Original Message ----- From: "Au-Yeung, Stella H" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, March 12, 2004 3:31 PM Subject: Someone out there must have done this with Struts 1.0 > Has someone out there successfully set the "selected" option of a > <html:select> under Struts 1.0? > > What I try to do is to set the option as "selected" when "userId" > matches > "shopWorkOrder.engineerId": > <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> > > I tried the following two things based on all your input but still > can't get > it working: > Using optionsCollection -----> > 1) The following gave a compilation error claiming doesn't recognize > "optionsCollection". I think this is a Struts 1.0 problem. > > <bean:define id="eList" name="ShopWorkOrderFormBean" > property="engineerList"/> > > <html:select property="shopWorkOrder.engineerId"> > > <html:optionsCollection name="eList" value="userId" > label="commonName"/> > > </html:select> > > Using value"<%=...%>" -----> > 2) The following also gave a compilation error that it doesn't like > value"<%=...%>" > > <bean:define id="eList" name="ShopWorkOrderFormBean" > property="engineerList"/> > > <html:select property="shopWorkOrder.engineerId" > value="<%=shopWorkOrder.engineerId%>"> > > <html:options collection="eList" name="ShopWorkOrderFormBean" > property="userId" labelproperty="commonName"/> > > </html:select> > > I use debug statements inside the JSP to make sure there is a matching > userId: > > Eng id:<bean:write name="ShopWorkOrderFormBean" > property="shopWorkOrder.engineerId"/><br> > > <bean:define id="engrList" name="ShopWorkOrderFormBean" > property="engineerList"/> > > <logic:iterate id="element" name="engrList"> Label:<bean:write > > name="element" property="commonName"/> > > Value:<bean:write name="element" property="userId"/><br><br> > > </logic:iterate> > > > > Here's the output from the above debug: > > Eng id:8 > > Label:JOE ENGINEER XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXL Value:3 > > Label:VERLINDA BROOME Value:NZW32M > > Label:FRANK WHITON Value:NZ7Z1Q > > Label:Another Active Engineer Value:8 > > Setting the "selected" in a <html:select> is a very basic operation. I > can't see that being a bug in Struts 1.0. But somehow it doesn't work. > Has anyone done it successfully before??? > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]