Hi Kev, Sorry - I missed the fieldName being dynamic bit(!). I think you may want to consider moving to JSTL for the loop bit so it will save having to do conversions but I think the following will achieve what you're trying to do:
<bean:define id="fieldNameBean" value="<%=fieldName%>" /> <c:out value="${instanceForm.dynamic.map[fieldNameBean]}" default="uh?" /> BTW you could remove the default="uh?" bit - I use this for testing so that I can at least see the loop working. I don't tend to mix EL with non-EL so this may not be the optimum solution - someone else may have a better idea - as I guess the performance will be slower and heavier due to having to copy a value to a bean in page scope. Hue. > -----Original Message----- > From: Kevin A. Palfreyman [mailto:[EMAIL PROTECTED] > Sent: 27 August 2003 11:32 > To: Struts Users Mailing List > Subject: RE: Problem converting from Struts tags to JSTL > > > Thanks for the pointer to the user guide, but unfortunately it doesn't > help. > > I tried: > > <c:out value="${instanceForm.dynamic.map.<%=fieldName%>}" /> > > And > > <c:out value='<%="${instanceForm.dynamic.map."+fieldName+"}"%>' /> > > And > > <c:out value="${instanceForm.dynamic.map.${fieldName}}" /> > > But those didn't work either. > > I think the problem is with the nested evaluation - combining the > scriptlet and the EL. > > Any other ideas? > > Kev > > > -----Original Message----- > > From: Hue Holleran [mailto:[EMAIL PROTECTED] > > Sent: 27 August 2003 10:21 > > To: Struts Users Mailing List > > Subject: RE: Problem converting from Struts tags to JSTL > > > > > > Try the User Guide: > > > > > > http://jakarta.apache.org/struts/userGuide/building_controller > > .html#dyna_act > > ion_form_classes > > > > > -----Original Message----- > > > From: Kevin A. Palfreyman [mailto:[EMAIL PROTECTED] > > > Sent: 27 August 2003 10:05 > > > To: [EMAIL PROTECTED] > > > Subject: Problem converting from Struts tags to JSTL > > > > > > > > > Hello, > > > > > > I'm trying to convert some pages from Struts tags to JSTL > > for the next > > > iteration of our product and I've hit a problem. [Struts > > 1.1, Tomcat > > > 4.1.24, Java 1.4.2, JSTL 1.0.3] > > > > > > I need to be able to dynamically access nested fields of my form > > > object. > > > > > > The Form object (instanceForm) contains a DynaBean > > (dynamic) as one of > > > its fields. The fields of the DynaBean are what I'm trying > > to access. > > > The name of the particular field within the DynaBean is stored in a > > > local variable (fieldName) that is been populated in a loop. > > > > > > The following Struts tag works fine: > > > > > > <bean:write name="instanceForm" property='<%= "dynamic."+fieldName > > > %>'/> > > > > > > I'm new to JSTL, and I've tried various forms similar to > > those below > > > without success. Is what I'm trying to do possible? > > > > > > <c:out value='<%= "${instanceForm.dynamic."+fieldName %>}' > > /> <c:out > > > value="${instanceForm.dynamic.<%=fieldName%>}" /> <c:out > > > value="${instanceForm.dynamic.${fieldName}}" /> > > > > > > Anyone have any ideas? Or should I stick with the Struts tags for > > > this? > > > > > > Thanks in advance, > > > > > > Kev > > > > > > > > > --- > > > Dr. Kevin Palfreyman > > > Apama (UK) Ltd, > > > Cambridge, UK > > > > > > > > > --- > > > Incoming mail is certified Virus Free. > > > Checked by AVG anti-virus system (http://www.grisoft.com). > > > Version: 6.0.512 / Virus Database: 309 - Release Date: 19/08/2003 > > > > > --- > > Outgoing mail is certified Virus Free. > > Checked by AVG anti-virus system (http://www.grisoft.com). > > Version: 6.0.512 / Virus Database: 309 - Release Date: 19/08/2003 > > > > > > --------------------------------------------------------------------- > > 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] > > > --- > Incoming mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.512 / Virus Database: 309 - Release Date: 19/08/2003 > --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.512 / Virus Database: 309 - Release Date: 19/08/2003 --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]