On Monday, July 29, 2002, at 09:30 AM, J�r�me BERNARD wrote:
> Hi,
hi J�r�me
> I need to create objects with no-default constructors�
>
> The object I want to create needs a string in the constructor call and
> even with ObjectCreationFactory, I can�t figure out how to solve this
> issue.
>
> Ideally, I would like to have a solution for the case where the string
> is an attribute of the current XML tags, or the body of it.
there are ways to pass in the string when it's an attribute of the current
xml tag.
one way is to use an anonymous subclass of AbstractObjectCreationFactory.
for example something like
digester.addFactoryCreate(
"/a/b",
new AbstractObjectCreationFactory() {
createObject(Attribute attributes) {
return new
XXX(attributes.getValue("attribute-name");
}
}
but when it comes to creating an object with the body text, i don't think
that a suitable rule exists in digester (at the moment).
it should be fairly easy to create one. one wrinkle is that the object
would only be pushed onto the stack when the end tag (for the element) is
created (whereas a standard object creation works when the start element
tag is encountered). some standard rules (like SetProperties) probably won'
t work with objects created in this manner. i'm not sure whether this
would be a problem for you or not.
- robert
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>