You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Johan Compagner <jc...@j-com.nl> on 2001/01/20 14:30:31 UTC

How can i implement this? (dynamic properties instead of static ones)1

Hi,

I have a form: PropertyForm
which have a getProperty(String) and a setProperty(String,Object)
So not a get and setter for every property.
That property form relay's those calls to a DbObject that also has those
getProperty and setProperty.
At start (first request of) i set a specifiek DbObject in a PropertyForm
that DbObject get's filled from a database. 
So when i want to add another var, i only have to change the object definition
in the database. Don't have to alter class files (this is not an option must be complety configurable)

But now i have a problem with the popupate of the with the TAG's:
they do this:
   match = BeanUtils.getProperty(bean, property);  (RadioTag)
or this:
   Object objvalue = PropertyUtils.getProperty(bean, property); (BaseFieldTag)

(why those 2 different calls to BeanUtils or PropertyUtils?) 

What must i do so that they don't try to find the rigth getter for that 
property but if it is a PropertyForm just call the getProperty(String property) ??

Must i really reimplemt all the TAGS????
As far as i can see it would be nice to have a method added to all those tag's 
or just one in the base tag: 

protected String getProperty(Object bean, String property)
{
    // Default Implementation
    return BeanUtils.getProperty(bean, property); (or PropertyUtils)
}
And all the calls for getting the property call's this method.
Then i can subclass all (or neccessary) Tag's and only reimplemnt that getProperty(Object,String) method.

For struts the  behaviour isn't changed. Only you are somewhat flexibler.

Or is there an other approache that i am not seeing at this time?

There are other problems of course when using one Form for more then one Form that my site haves.
Because the current implementation will reuse the same form bean when calling a specifiek action isn't it?

so if i call:

/nextpage.do?thema=pension
or
/nextpage.do?thema=xxxxxxx

Then the same property form will be used?
But i want to use the same Class: PropertyForm.class
but it will get another DbObject (xxxxxxx DbObject instead of a pension) 
so it will have different property's

But this behaviour is pretty simple to change just: reimplement one method: processActionForm(xx,xxx,xx)

Johan C.