commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "petra staub" <cal...@hotmail.com>
Subject Digester: dynamic property setter
Date Tue, 20 Jul 2004 08:43:36 GMT

Hi

I think this is a trivial question but as I am quite a newbie with
digster, I dare to pose it... ;-)

How can I implement a dynamic property setter?

I have for instance a bean 'address' with different properties and
getter/setters...something like:

public class Address {
  private String firstname;
  private String lastname;
  ...
  ...

  public void setFirstname(String str) {
    firstname = str;
  }
  public String getFirstname() {
    return firstname;
  }
  ...
  ...
}

I want now to parse a XML file where the bean properties are
specified by a 'property tag':

<address>
  <property id="firstname">petra</property>
  <property id="lastname">staub</property>
</address>

What rule do I have to apply for this?
I want to dynamically call the setter method on the bean what
is specified by the attribute 'id'...

I am able to solve this with the existing rules, if I know what
setter I actually want to call. A workaround would be to add
a 'addProperty(key,value)' method to the bean and implement
so a 'DynaBean'...but maybe this can be done with Digester
without this???

Thanks for any help or suggestions!

_________________________________________________________________
Sie wollen die letzten Nachrichten oder Ihr eigenes Horoskop per SMS 
erhalten? http://www.msn.ch/mobile/


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message