commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dimitri Frederickx" <dimi...@aircrew.be>
Subject RE: [Digester] How to map html-td elements to methods?
Date Fri, 30 Dec 2005 22:49:38 GMT
Thanks a lot, I'll try to make my own rule. To add a rule, do I always have
to do that in java the way you described it, or can I also add the rule by
configuring it in the xml-file? Normally I always describe my rules in xml,
and this way a can keep all the rules at one place. Can I do that or does it
has to be in java?

Regards,
Dimitri


-----Original Message-----
From: Simon Kitching [mailto:skitching@apache.org] 
Sent: vrijdag 30 december 2005 23:40
To: Jakarta Commons Users List
Subject: Re: [Digester] How to map html-td elements to methods?

On Fri, 2005-12-30 at 14:41 +0100, Dimitri Frederickx wrote:

>    <td class="command">open</td>
>    <td class="target">./tests/html/test_open.html</td>
>  
> 
> I want that the value of the class-attribute maps to the property (and
> method name), and the value of the tag must be the value to pass to this
> method.
> 
> Is there a way to do this with digester? Does anyone has done something
like
> this? It would help me a lot, because I'm really stuck at this moment.

I don't believe there is an existing rule that does exactly what you
want, but you should be able to create your own rule to achieve your
goal. I would suggest starting with BeanPropertySetterRule, then
modifying the begin method so that it saves away the target property
name in a member variable for later use. Using member variables like
that isn't actually a good idea in general (doesn't work when rules are
nested) but in this case it's fine as this rule won't be nested.

Don't be concerned about creating your own rule; that's not unusual, nor
particularly difficult.

Once you've got your custom rule class, just add it do digester like:
  digester.addRule("tbody/tr/td", new MyNewRule());

Regards,

Simon


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





---------------------------------------------------------------------
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