You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jim Collins <ja...@blueyonder.co.uk> on 2003/08/04 21:30:35 UTC

OT Digester question

Appologies for the off topic question. Does anyone know how I can create an
object with a constructor that takes agruments specified via XML elements.

I have a Configuration object with a constructor that takes two String
parameters. The XML will be something like this:

<config>
    <param1>someText</param1>
    <param2>someText</param2>
    <saveAs>someText</savaAs>
</config>

When the digester matches the config pattern it will create the
Configuration object passing param1 and param2 as parameters to the
constructor and then when it matches the pattern config/saveAs it will call
a method on the Configuration object.

I have looked at the documentation and have seen the FactoryCreateRule but I
am not sure how to use this and how I can get it to use the param1 and
param2 elements as the Constructor parameters.

Once again sorry for the off topic post. Any hints would be appreciated.

Thanks

Jim.


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


Re: [OT] Digester question

Posted by Jim Collins <ja...@blueyonder.co.uk>.
I haven't got it to work yet but you confirmed what I thought about not
being able to use nested tags and having to use attributes instead. I am
just checking out now how to use the FactoryCreateRule.

Jim.
----- Original Message -----
From: "Kris Schneider" <kr...@dotech.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Monday, August 04, 2003 9:06 PM
Subject: Re: [OT] Digester question


> Um, so, that actually worked? ;-)
>
> Quoting Jim Collins <ja...@blueyonder.co.uk>:
>
> > Kris,
> >
> > Thanks for the help.
> >
> > Jim.
> > ----- Original Message -----
> > From: "Kris Schneider" <kr...@dotech.com>
> > To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > Sent: Monday, August 04, 2003 8:46 PM
> > Subject: Re: [OT] Digester question
> >
> >
> > > A bit out of my comfort zone on this one, but I think you might have
to
> > change
> > > your XML to something like:
> > >
> > > <config attr1="someText" attr2="someText">
> > >   <saveAs>someText</savaAs>
> > > </config>
> > >
> > > because the FactoryCreateRule/ObjectCreationFactory stuff seems to
work
> > with an
> > > element's attributes, not its sub-elements. Then it looks like you
need
> > to
> > > subclass AbstractObjectCreationFactory and provode a createObject
method
> > impl
> > > that will extract the appropriate attribute values and construct your
> > > Configuration object. I'm sure other folks on the list (or on
> > commons-user) have
> > > more experience with this though...
> > >
> > > Quoting Jim Collins <ja...@blueyonder.co.uk>:
> > >
> > > > Appologies for the off topic question. Does anyone know how I can
> > create
> > an
> > > > object with a constructor that takes agruments specified via XML
> > elements.
> > > >
> > > > I have a Configuration object with a constructor that takes two
String
> > > > parameters. The XML will be something like this:
> > > >
> > > > <config>
> > > >     <param1>someText</param1>
> > > >     <param2>someText</param2>
> > > >     <saveAs>someText</savaAs>
> > > > </config>
> > > >
> > > > When the digester matches the config pattern it will create the
> > > > Configuration object passing param1 and param2 as parameters to the
> > > > constructor and then when it matches the pattern config/saveAs it
will
> > call
> > > > a method on the Configuration object.
> > > >
> > > > I have looked at the documentation and have seen the
FactoryCreateRule
> > but
> > > > I
> > > > am not sure how to use this and how I can get it to use the param1
and
> > > > param2 elements as the Constructor parameters.
> > > >
> > > > Once again sorry for the off topic post. Any hints would be
> > appreciated.
> > > >
> > > > Thanks
> > > >
> > > > Jim.
> > >
> > > --
> > > Kris Schneider <ma...@dotech.com>
> > > D.O.Tech       <http://www.dotech.com/>
>
> --
> Kris Schneider <ma...@dotech.com>
> D.O.Tech       <http://www.dotech.com/>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


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


Re: [OT] Digester question

Posted by Kris Schneider <kr...@dotech.com>.
Um, so, that actually worked? ;-)

Quoting Jim Collins <ja...@blueyonder.co.uk>:

> Kris,
> 
> Thanks for the help.
> 
> Jim.
> ----- Original Message -----
> From: "Kris Schneider" <kr...@dotech.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Monday, August 04, 2003 8:46 PM
> Subject: Re: [OT] Digester question
> 
> 
> > A bit out of my comfort zone on this one, but I think you might have to
> change
> > your XML to something like:
> >
> > <config attr1="someText" attr2="someText">
> >   <saveAs>someText</savaAs>
> > </config>
> >
> > because the FactoryCreateRule/ObjectCreationFactory stuff seems to work
> with an
> > element's attributes, not its sub-elements. Then it looks like you need
> to
> > subclass AbstractObjectCreationFactory and provode a createObject method
> impl
> > that will extract the appropriate attribute values and construct your
> > Configuration object. I'm sure other folks on the list (or on
> commons-user) have
> > more experience with this though...
> >
> > Quoting Jim Collins <ja...@blueyonder.co.uk>:
> >
> > > Appologies for the off topic question. Does anyone know how I can
> create
> an
> > > object with a constructor that takes agruments specified via XML
> elements.
> > >
> > > I have a Configuration object with a constructor that takes two String
> > > parameters. The XML will be something like this:
> > >
> > > <config>
> > >     <param1>someText</param1>
> > >     <param2>someText</param2>
> > >     <saveAs>someText</savaAs>
> > > </config>
> > >
> > > When the digester matches the config pattern it will create the
> > > Configuration object passing param1 and param2 as parameters to the
> > > constructor and then when it matches the pattern config/saveAs it will
> call
> > > a method on the Configuration object.
> > >
> > > I have looked at the documentation and have seen the FactoryCreateRule
> but
> > > I
> > > am not sure how to use this and how I can get it to use the param1 and
> > > param2 elements as the Constructor parameters.
> > >
> > > Once again sorry for the off topic post. Any hints would be
> appreciated.
> > >
> > > Thanks
> > >
> > > Jim.
> >
> > --
> > Kris Schneider <ma...@dotech.com>
> > D.O.Tech       <http://www.dotech.com/>

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

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


Re: [OT] Digester question

Posted by Jim Collins <ja...@blueyonder.co.uk>.
Kris,

Thanks for the help.

Jim.
----- Original Message -----
From: "Kris Schneider" <kr...@dotech.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Monday, August 04, 2003 8:46 PM
Subject: Re: [OT] Digester question


> A bit out of my comfort zone on this one, but I think you might have to
change
> your XML to something like:
>
> <config attr1="someText" attr2="someText">
>   <saveAs>someText</savaAs>
> </config>
>
> because the FactoryCreateRule/ObjectCreationFactory stuff seems to work
with an
> element's attributes, not its sub-elements. Then it looks like you need to
> subclass AbstractObjectCreationFactory and provode a createObject method
impl
> that will extract the appropriate attribute values and construct your
> Configuration object. I'm sure other folks on the list (or on
commons-user) have
> more experience with this though...
>
> Quoting Jim Collins <ja...@blueyonder.co.uk>:
>
> > Appologies for the off topic question. Does anyone know how I can create
an
> > object with a constructor that takes agruments specified via XML
elements.
> >
> > I have a Configuration object with a constructor that takes two String
> > parameters. The XML will be something like this:
> >
> > <config>
> >     <param1>someText</param1>
> >     <param2>someText</param2>
> >     <saveAs>someText</savaAs>
> > </config>
> >
> > When the digester matches the config pattern it will create the
> > Configuration object passing param1 and param2 as parameters to the
> > constructor and then when it matches the pattern config/saveAs it will
call
> > a method on the Configuration object.
> >
> > I have looked at the documentation and have seen the FactoryCreateRule
but
> > I
> > am not sure how to use this and how I can get it to use the param1 and
> > param2 elements as the Constructor parameters.
> >
> > Once again sorry for the off topic post. Any hints would be appreciated.
> >
> > Thanks
> >
> > Jim.
>
> --
> Kris Schneider <ma...@dotech.com>
> D.O.Tech       <http://www.dotech.com/>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


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


Re: [OT] Digester question

Posted by Kris Schneider <kr...@dotech.com>.
A bit out of my comfort zone on this one, but I think you might have to change
your XML to something like:

<config attr1="someText" attr2="someText">
  <saveAs>someText</savaAs>
</config>

because the FactoryCreateRule/ObjectCreationFactory stuff seems to work with an
element's attributes, not its sub-elements. Then it looks like you need to
subclass AbstractObjectCreationFactory and provode a createObject method impl
that will extract the appropriate attribute values and construct your
Configuration object. I'm sure other folks on the list (or on commons-user) have
more experience with this though...

Quoting Jim Collins <ja...@blueyonder.co.uk>:

> Appologies for the off topic question. Does anyone know how I can create an
> object with a constructor that takes agruments specified via XML elements.
> 
> I have a Configuration object with a constructor that takes two String
> parameters. The XML will be something like this:
> 
> <config>
>     <param1>someText</param1>
>     <param2>someText</param2>
>     <saveAs>someText</savaAs>
> </config>
> 
> When the digester matches the config pattern it will create the
> Configuration object passing param1 and param2 as parameters to the
> constructor and then when it matches the pattern config/saveAs it will call
> a method on the Configuration object.
> 
> I have looked at the documentation and have seen the FactoryCreateRule but
> I
> am not sure how to use this and how I can get it to use the param1 and
> param2 elements as the Constructor parameters.
> 
> Once again sorry for the off topic post. Any hints would be appreciated.
> 
> Thanks
> 
> Jim.

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

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