Help with nesting tags (STRUTS)
Hi,
I'm having a few problems with the following nested tag:
<input name="indicator_target_<bean:write name='indicators' property='indicator_id'/>" size="10" value="<bean:write name="TargetValuesActionForm" property="indicator_target_<bean:write name='indicators' property='indicator_id'/>"/>"/>
The page returns no getter method for "indicator_target_", but i'm not trying to get the "indicator_target_" value i'm trying to get the "indicator_target_ + id" (i.e. indicator_target_23) value. For some reason the nested _<bean:write name='indicators' property='indicator_id'/> tag which is part of the input 'value' param is being ignored?
anyone know how I can resolve this?
One of the first rules of JSP custom tags - you cannot use a tag as an attribute to another tag. For dynamic attributes you have to use a runtime expression. - either <%= expr %> or in a JSP2.0 container ${expr} as well.
Your "input" tag is plain template html. So you can use custom tags for the values of the attributes.
The one that is failing is
<bean:write name="TargetValuesActionForm" property="indicator_target_<bean:write name='indicators' property='indicator_id'/>"/>
I am presuming you are in a logic:iterate loop, or equivalent.
Something like this might work:
<bean:define id="currentId" name='indicators' property='indicator_id'/>
<bean:write name="TargetValuesActionForm" property="<%= "indicator_target_" + currentId %>"/>
However all of this is very nasty.
And struts can do at least part of this for you with indexed properties. You might want to take a look at them.
Hope this helps,
evnafets