Override STRUTS introspection
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Paul_Spencer
Posted On:   Thursday, November 29, 2001 07:26 AM

I have a Container class that reads a configuration file (currently there are several configurations and possibly more to come) in order to dynamically get data from the database. We store the data in a HashSet within the Container and is accessed through getAttribute("name") and setAttribute("name",value) methods. I have just recently installed STRUTS and it is working great with my design. However, I would like to include the ActionForm functionality. I have 2 problems with my current implementation. 1) The Container can load up to 100 attributes which, in my opion, is too many get/set methods to maintain. 2) The Container is loaded dynamically which makes it imp   More>>

I have a Container class that reads a configuration file (currently there are several configurations and possibly more to come) in order to dynamically get data from the database. We store the data in a HashSet within the Container and is accessed through getAttribute("name") and setAttribute("name",value) methods.

I have just recently installed STRUTS and it is working great with my design. However, I would like to include the ActionForm functionality.

I have 2 problems with my current implementation.

1) The Container can load up to 100 attributes which, in my opion, is too many get/set methods to maintain.

2) The Container is loaded dynamically which makes it impossible to create get/set methods for all attributes beforehand.

Is there a way to overload the method which does the introspection within STRUTS to use my get/set Attribute methods instead?

And which method handles the introspection?

If not any suggestions on how to mimic this functionality and still be able to integrate with the ActionForm STRUTS functionality?

   <<Less

Re: Override STRUTS introspection

Posted By:   Ted_Husted  
Posted On:   Thursday, December 6, 2001 09:25 AM

The Struts nigthly build provides additional methods for
getting and setting properties on an ActionForm. I'm told
that the following approach allows hashmaps to be accessed
directly via an ActionForm.



On the ActionForm, define these methods to access your map:


public void setProperty(String key, Object value)
public Object getProperty(String key)

then you can use this notation in the JavaServer Pages





and 





Of course, this does not speak to dynamically writing
tags for whatever fields that need to be input at runtime,
or how a dynamic set of fields would be validated.


Do keep in mind that the purpose of the ActionForm is
to buffer input. You do not need to use ActionForm for
simply writing to a page, only when writing values to a
HTML form to be put back in again.


HTH -Ted

About | Sitemap | Contact