Currently, every form field has to have equivalent field in ActionForm bean,
with both getter and setter method. This requires that a new ActionForm be
generated for each new Struts form (with additional fields).

Our applicaiton requires 'extensibility', ie. HTML/JSP designer should be
able to add new fields to the form without breaking serverside Java code,
including Struts. 

I've made some minor changes to Struts 0.5 to achieve such extensibility.
Basically, it use a Hashtable to save and retrieve extra fields that do not
appear in the ActionForm.

1. Add (Hashtable) properties to BaseActionForm which implements
ValidatingActionForm, with getter and setter methods like,

    public String get(String name);

    public void set(String name, String value);

  All my ActionForm classes will extend this BaseActionForm.

2. Added a new util class that has two methods that will call the above
methods with the following interface:

    public static String getPropertyValue(Object bean, String name)
        throws IllegalAccessException, InvocationTargetException,
NoSuchMethodException;

    public static void setPropertyValue(Object bean, String name, Object
value)
        throws IllegalAccessException, InvocationTargetException,
NoSuchMethodException;

3. Modify org.apache.struts.util.BeanUtils' get/setPropertyValue() to call
my custom get/setPropertyValue() above whenever NoSuchMethodException was
thrown.


This approch worked so far but not very elegant. The need to modify
BeanUtils.java is, of cause, troublesome. Any suggestions?

Thanks.

Kevin

Reply via email to