You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Toni Charlot <to...@fdplus.com> on 2002/07/14 21:23:46 UTC

Referencing BeanUtils.described Mapped nested property from JSP

I have the following scenario:
Class: Employee
members: String: name; Address:address;

Class: Address
members: String:street; String:city

on the Action Form I have: Map: properties, with "property" getters a la Ted's SuperForm;

I populate properties using the "magical" BeanUtils:
properties = BeanUtils.describe(employee);

Question 1:
How do I refer to the address on the jsp.
property="property(name)" -> works for employee but
property="property(address(city))" or
property="property(address.city)" or
property="property(address,city)" will not work for the address attributes.

Question 2:
Does BeanUtils.describe convert the nested objects to map as well? For example would the employee address attribute be a map as well;
?? Map addr = (Map)porperties.get("address")

Thank you.



Re: Referencing BeanUtils.described Mapped nested property from JSP

Posted by Toni Charlot <to...@fdplus.com>.
Question 1:
  As I was writting the question I saw a possible solution:
 I wrote getter/setter method "nestedProperty" then tried accessing them the
following ways with no success:
     property="nestedProperty(address.city)" or
    property="nestedProperty(address,city)


    /**
     */
    public void setNestedProperty(String key, String nestedKey, Object
value) {
        if (isMutable()){
            ((Map)getProperty(key)).put(nestedKey,value);
        }
    }


    /**
     */
    public Object getNestedProperty(String key, String nestedKey) {
        return ((Map)getProperty(key)).get(nestedKey);
    }


----- Original Message -----
From: "Toni Charlot" <to...@fdplus.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Sunday, July 14, 2002 3:23 PM
Subject: Referencing BeanUtils.described Mapped nested property from JSP


I have the following scenario:
Class: Employee
members: String: name; Address:address;

Class: Address
members: String:street; String:city

on the Action Form I have: Map: properties, with "property" getters a la
Ted's SuperForm;

I populate properties using the "magical" BeanUtils:
properties = BeanUtils.describe(employee);

Question 1:
How do I refer to the address on the jsp.
property="property(name)" -> works for employee but
property="property(address(city))" or
property="property(address.city)" or
property="property(address,city)" will not work for the address attributes.

Question 2:
Does BeanUtils.describe convert the nested objects to map as well? For
example would the employee address attribute be a map as well;
?? Map addr = (Map)porperties.get("address")

Thank you.





--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>