You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Joel Hockey <jo...@qsipayments.com> on 2002/01/21 00:09:46 UTC

RE: intake and business object mapping: confusing StringKey with String in setProperies

Thanks for that.

I looked through the code and realised that the problem was being caused by
java's introspection.

Introspection looks for a getter if it exists and sees what type is
returned.  It then uses that same type for the setter.  (This is in
jdk1.3.1, others may be different as you said)

The field that I was having trouble with was a torque String type, but
because it is the primary key, torque generates a getter with a StringKey
type return.

I ended up changing around my torque schema.  I now have an auto generated
integer id for the primary key, and kept the other field as a string.  This
has fixed the problem.


> -----Original Message-----
> From: John McNally [mailto:jmcnally@collab.net]
> Sent: Thursday, January 17, 2002 3:00 PM
> To: Turbine Users List
> Subject: Re: intake and business object mapping: confusing StringKey
> with String in setProperies
> 
> 
> This is a problem with java's bean introspection classes.  It is
> difficult to fix as there are bugs in different classes in 
> different jdk
> versions.  The version in cvs will work for jdk1.3.x, I believe.  You
> can remove the String convenience method from torque's Object.vm
> template and regenerate your sources for an easier fix.
> 
> john mcnally
> 
> 
> Joel Hockey wrote:
> > 
> > I've just started using turbine for a GSM SMS payment 
> gateway application
> > that I am writing.  The idea is to allow builders and 
> plumbers and whatever
> > to take credit card payments using their mobile phone.
> > 
> > Anyway, I'm using turbine for the web side of things and 
> I've run into a
> > problem with intake.
> > 
> > I am using intake with mapping to my business object.  (I 
> don't have my
> > exact source with me right now, but it is along the lines of)
> > 
> > <group name="Merchant" key="merchant" mapToObject="om.Merchant">
> >     <field name="Merid" key="merid" type="String">
> >         <rule name="minLength" value="8">Merchant Id must 
> be at least 8
> > long</rule>
> >           <rule name="maxLength" value="16">Merchant Id 
> must not be longer
> > than 16</rule>
> >     </field>
> > .
> > .
> > .
> > </group>
> > 
> > I used torque to generate my Merchant business object.  The 
> primary key is
> > the field Merid.  The generated MerchantBase class has two 
> methods to set
> > the Merid:
> > setMerid(String s), and setMerid(StringKey sk)
> > 
> > In a screen class for a page where I either create or edit 
> a merchant, I
> > check for a merchant Id as a parameter from the previous 
> request.  If no id
> > exists, then I create a new merchant object and put it in 
> the context for
> > velocity and also in the ServletContext.
> > 
> > My action class to handle the submission of the form does
> > 
> >         Merchant mer =
> > (Merchant)data.getServletContext().getAttribute("merchant");
> >         Group g = intake.get("Merchant", mer.getMerid());
> >         g.setProperties(mer);
> > 
> > When I call g.setProperties() I am getting an 
> InvocationTargetException at
> > line 663 in 
> org.apache.turbine.services.intake.model.Field.setProperty().
> > 
> > The problem is that the field is using the method 
> setMerid(StringKey sk),
> > but is passing in a String.
> > 
> > Why is intake using the setter method that takes a 
> StringKey rather than the
> > setter method that takes a String?
> > 
> > Thanks,
> > 
> > Joel Hockey
> > 
> > 
> > 
> > --
> > To unsubscribe, e-mail:   
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>