You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Stefan Wachter <st...@gmx.de> on 2001/11/26 12:24:54 UTC

proposal for map properties in form beans (call for comments)

Dear all,

I have a lot of form bean classes that store their values in maps. Currenty
I must implement lots of similar getter and setter methods in each form bean
class in order to allow struts to access these values. E.g.

public String getName() {
   return (String)myValues.get("name");
}

public void setName(String aString) {
  myValues.put("name", aString);
}

My proposal is to enable struts to directly access values in maps. For
example a bean can have a map valued-property "values" (i.e. the method "public
Map getValues();"). Now I want to access a value in this map exactly as if it
was a normal property. For example in JSP:

<bean:write name="formBean" property="value.name"/>

The big advantage of this feature would be that I can drive the application
with meta-data. Adding a new property does not need the form beans to be
touched. Even the JSP could be prepared to generate additional fields.

Unfortunately when I scanned the struts sources I found that this kind of
extension is problematic because currently properties are accessed by the
java.beans.ProperyDescriptor instances. I think that the access would have to be
changed to use reflection directly.

Has someone coments or suggestions on this topic?

Ciao,
Stefan


PS: This mechanism of accessing mapped values is built into the web-objects
framework.

-- 
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net


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