I have a top level
JSP that <jsp:include>'s a JSP which contains form fields. This second included JSP contains common fields that are reused among other top level JSP pages. The different jsp pages. are backed by different (
Struts) form beans, and have different levels of nested beans.
What I did to make the form consistent was pass in a parameter for a "prefix", that is the notation of the nested beans up to the nested bean that contains these form fields.
so I have
on the first invocation, and
on the second top level form, which has different nested bean structure, but the same leaf bean instance the form is working with, an instance of a mailing address bean.
then in the included form JSP:
This part works nicely.
Now I am adding some conditional logic, like
where form is a page context attribute of the form bean instance.
This works in the first case, where the prefix represents the simple single bean name (address), but fails when it is a compound value (location.address).
I have been able to get around the expression language not working by using a scriptlet that calls the beanutils:
In other cases, I would also want to do something like this with indexed beans,
such as when prefix = "locations.item[1].locationModel".
I also tried writing the entire expression out.
I am also able to use the scriptlet calling beanutils like I did above to get around this, but it is not as elegant as I would like it to be,
and this really gets complicated when I would want to use the variable expression with <c:forEach items="${form[prefix].config.columns}" type of places.
So I was wondering if there was a better way to do this using the expression language syntax.
That is, it is possible for the expression language evaluate the value of a variable expression ?
I am using
Servlet 2.4, JSP 1.2, JSTL 1.1
[ July 09, 2006: Message edited by: Travis Hein ]