You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Adrian Mitev <ad...@googlemail.com> on 2006/11/30 14:42:46 UTC

[Digester] Question about digester rules

Hi all. I got the following XML

<regex-validators>
 <regex-validator>
        <type>digitField</type>
        <expression>\d+</expression>
        <messags>
          <message>
            <local>en</local>
            <text>Only digit values are allowed</text>
          </message>
        </messags>
 </regex-validator>
</regex-validators>

Here is my bean

public class RegexValidatorType {

    private String expression;

    private HashMap messages;

    private String type;

    //getters and settters here
 ........
}

I want to strore All regex-validators in ArrayList of RegexType bean and to
store the messages in HashMap with key <local> and value <text>. How to do
that inserting in the map with digester?


This is my code without the messages mapping:

digester.addObjectCreate("regex-validators", ArrayList.class);
digester.addObjectCreate("regex-validators/regex-validator",
RegexValidatorType.class);
digester.addBeanPropertySetter("regex-validators/regex-validator/type",
"type");
digester.addBeanPropertySetter("regex-validators/regex-validator/expression",
"expression");
digester.addSetNext("regex-validators/regex-validator", "add");