commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kumar Pankaj" <Pankaj.Ku...@drei.com>
Subject RE: [digester] How to call a constructor with my own values(rather than theXML attributes or elements)
Date Wed, 22 Oct 2003 10:29:51 GMT
Thanks Simon, 

I will wait for sometime when the ObjectParamRule can be invoked from xmlrules. 

For time being, I found a work around for that. I made 2 category classes Film and Literature
which are extending my base class Content. In the constructor (no arg) of Film and Literature,
I am setting the category of Content to Film/Literature. And in rules.xml, Insteading of instantiating
the Content class, now i am instantiating Film/Literature class. That works fine till now
:-) But yah, it is hardcoding and not a permanent solution. 

Thanks again,
Pankaj


-----Original Message-----
From: Simon Kitching [mailto:simon@ecnetwork.co.nz]
Sent: Wednesday, October 22, 2003 1:00 AM
To: commons-user@jakarta.apache.org
Cc: Kumar Pankaj
Subject: RE: [digester] How to call a constructor with my own
values(rather than theXML attributes or elements)


Hi Kumar,

The ObjectParamRule can't currently be invoked from xmlrules, nor can
the PathCallParamRule.

A patch for ObjectParamRule support in xmlrules has been submitted on
the development email list, but the Digester maintainers haven't yet
evaluated it.

So you could search the dev list for that email and compile the attached
code yourself. Or if you can wait 1-2 weeks, I think the odds are fairly
good that one of the maintainers will have committed the patch by then;
at that point you could use a nightly snapshot of Digester.

If xmlrules allows you to invoke FactoryCreateRule to create your class
instance, then you could implement a factory class which creates your
object and then passes the appropriate value for the "content" attribute
of your object.

Or you could change to using the digester API (rather than xmlrules)
until this is sorted out.

Regards,

Simon


On Tue, 2003-10-21 at 20:27, Kumar Pankaj wrote:
> Hi Simon,
> 
> Do you know the equivalent of ObjectParamRule that can be specified in the Digester Rules
XML (i mean via). Is it a sub element under <call-method-rule> element ? Do i have to
download the new digester version, i have 1.5 version. 
> 
> Sorry for so many questions. i am rookie in Digester
> 
> thanks,
> Pankaj 
> -----Original Message-----
> From: Simon Kitching [mailto:simon@ecnetwork.co.nz]
> Sent: Monday, October 20, 2003 10:36 PM
> To: Jakarta Commons Developers List
> Subject: Re: How to call a constructor with my own values (rather than
> theXML attributes or elements)
> 
> 
> Hi Kumar,
> 
> 
> You can use the ObjectParamRule to pass literal strings (or other
> objects) to methods.
> 
> There is also a PathCallParamRule class in CVS, but it was added since
> the last release so you would need to download it from CVS.
> 
> Regards,
> 
> Simon
> 
> On Tue, 2003-10-21 at 03:03, Kumar Pankaj wrote:
> > Hi Gurus,
> > 
> > I have been totally stumped by this.
> > I want to set a property in Java bean based on the pattern (it does not have any
attributes)
> > Following is my simple XML
> > 
> >              <?xml version="1.0" encoding="UTF-8"?>
> >              <content>
> > 			<Film>
> > 				<Keyword>Tom Cruise</Keyword>
> > 				<Headline>
> > 					<TextTitleHi>Mission Impossible</TextTitleHi>
> > 				</Headline>
> > 			</Film>
> > 			<Literature>
> > 				<Keyword>Vikram Seth</Keyword>
> > 				<Headline>
> > 					<TextTitleHi>Principles of Life</TextTitleHi>
> > 				</Headline>
> > 			</Literature>
> > 		</content>
> > 
> > 
> > For this, i want to create a single Java object named Content and set the propoerty
called category to Film when it comes to Film pattern. Now, I have not been able to use either
<set-properties-rule> or <call-method-rule> because none of them can pass the
pattern name as parameters to the methods.
> > 
> > Thanks in Advance,
> > Pankaj 
> > 
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-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