Thank you Kris! Quoting Kris Schneider <[EMAIL PROTECTED]>:
> Here's a quick test page that emulates what it sounds like you want to do. > The > <bean:write> seems to work fine. > > <%@ page contentType="text/plain" %> > <%@ taglib prefix="bean" uri="http://jakarta.apache.org/struts/tags-bean" > %> > <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> > > <jsp:useBean id="person" class="java.util.HashMap"> > <jsp:useBean id="name" class="java.util.HashMap"> > <c:set target="${name}" property="firstName" value="Kris"/> > <c:set target="${name}" property="lastName" value="Schneider"/> > </jsp:useBean> > <c:set target="${person}" property="name" value="${name}"/> > </jsp:useBean> > > <c:set var="nestedProp" value="name.firstName"/> > > person: <c:out value="${person}"/> > person.name: <c:out value="${person.name}"/> > person.name.firstName: <c:out value="${person.name.firstName}"/> > > <jsp:useBean id="nestedProp" type="java.lang.String"/> > bean:write: <bean:write name="person" property="<%= nestedProp %>"/> > > Quoting [EMAIL PROTECTED]: > > > Never mind... that didn't fix it either. property is a property of > target, > > which is another object. > > > > Carl > > > > Quoting [EMAIL PROTECTED]: > > > > > Kris, > > > > > > Thanks for your tip. You lead me to the answer. Here is what works: > > > > > > <c:set var="person" value="${requestScope.personForm}"/> > > > <c:set var="nestedProp" value="name.firstName"/> > > > <c:set var="val" value="${nestedProp}" property="${person}" /> > > > > > > Now, we can all stand around and scratch our heads and say "Duh! Why > > didn't > > > I > > > think of that?" Setting the person as the property tells JSTL to use > > > person > > > as a bean and allows it to do normal nested queries on nestedProp. > Oh > > man > > > do > > > I feel like a dummy. > > > > > > Carl > > > > > > Quoting Kris Schneider <[EMAIL PROTECTED]>: > > > > > > > Then I don't see how to make it work with JSTL. So, "nestedProp" is > a > > > > scoped > > > > variable containing the nested property you want to access, right? > Does > > > > this > > > > work for you: > > > > > > > > <jsp:useBean id="nestedProp" type="java.lang.String"/> > > > > <bean:write name="personForm" property="<%= nestedProp %>"/> > > > > > > > > Unfortunately, I don't think Struts-EL provides a version of > > > <bean:write> > > > > or you > > > > could also try: > > > > > > > > <bean-el:write name="personForm" property="${nestedProp}"/> > > > > > > > > Quoting [EMAIL PROTECTED]: > > > > > > > > > No. The variable that is actually nestedProp is populated > > > dynamically. > > > > > > > > > Most > > > > > of the time it is just a single property name, but from time to > time, > > > > it > > > > > needs > > > > > to be nested. > > > > > > > > > > Carl > > > > > > > > > > Quoting Kris Schneider <[EMAIL PROTECTED]>: > > > > > > > > > > > Are you just trying to shorthand this: > > > > > > > > > > > > <c:out value="${person.name.firstName}"/> > > > > > > > > > > > > In other words, person.getName().getFirstName(). > > > > > > > > > > > > Quoting [EMAIL PROTECTED]: > > > > > > > > > > > > > JSTL is not nesting appropriately. Here is an example of what > I > > > am > > > > > > doing: > > > > > > > > > > > > > > <c:set var="person" value="${requestScope.personForm}"/> > > > > > > > <c:set var="nestedProp" value="name.firstName"/> > > > > > > > <c:out value="${person[nestedProp]}"/> > > > > > > > > > > > > > > The error that I am getting is: > > > > > > > Unable to find a value for "name.firstName" in object of > class > > > > > > > "org.team.Person" using operator "[]" (null) > > > > > > > > > > > > > > If nestedProp was just firstName (and Person had a firstName > > > > property) > > > > > > then > > > > > > > this works just fine. JSTL is not seeing the . and doing > > > > > > > getName().getFirstName() > > > > > > > > > > > > > > I have tried a number of combinations with [] and ' (escape) > and > > > \ > > > > and > > > > > > .... > > > > > > > nothing works :( Any help appreciated. > > > > > > > > > > > > > > > > > > > > > Carl > > > > > > > > > > > > -- > > > > > > Kris Schneider <mailto:[EMAIL PROTECTED]> > > > > > > D.O.Tech <http://www.dotech.com/> > > > > > > > > -- > > > > Kris Schneider <mailto:[EMAIL PROTECTED]> > > > > D.O.Tech <http://www.dotech.com/> > > -- > Kris Schneider <mailto:[EMAIL PROTECTED]> > D.O.Tech <http://www.dotech.com/> > > --------------------------------------------------------------------- > 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]

