Simper's representation of a database row is in the class SimperBean.
SimperBean is a relatively shallow extension of the DynaBean (actually
DynaBean is an interface -- BasicDynaBean is a concrete class which
SimperBean extends) -- see the commons project "BeanUtils" for the
source to DynaBean.
Table columns, as well as relations, are represented as dynamic
properties using the DynaBean/DynaClass mechanisms. It does NOT produce
"get" and "set" methods for each column or relation. Instead, there is a
single "get" method and a single "set" method, whose first parameter is
the property name. This isn't a Simper convention, it's a DynaBean
convention.
DynaBeans/DynaClasses are supported by the latest (nightly builds) of
the other "beanutils" classes, which is why the Struts tags like
<bean:write>, <logic:iterate>, etc., all work with SimperBeans (and why
I chose DynaBeans as a basis).
With all that said, I really don't know much about the new Nesting tags
or how they work. If they rely upon the same introspection mechanisms as
<logic:iterate>, <bean:write>, etc., then they should work with Simper
just fine. That's just a guess.
Bryan
On Wed, 2002-03-06 at 08:04, John Menke wrote:
>> Just give it a bash. Run a simper model through the NeXt tags. I lay my
>> money on it working as-is.
Sounds great. I will do this today. Just trying to understand the
internals a little better.
>> So as long as the simper beans have bean property conformity (eg:
>> getMyProperty, setMyProperty) then the beans are ready to go with NeXt
>> as they are wihout mods. I'd be very surprised if it needed mods,
>> really. You can use Castor types straight up because the properties are
>> valid bean properties.
I understand this it looks like Simper will create these methods property
methods
>> A nested bean is simply one object that is returned by the method of
>> another.
This is what was unclear to me. I guess when you create relations between
tables in Simper these get Methods to return another bean will be created in
the SimperBean automatically?
-----Original Message-----
From: Arron Bates [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 06, 2002 12:47 AM
To: Struts Users Mailing List
Subject: Re: simper-NeXt
Almost.
NeXt is only working off of Bean properties, and as with all beans, it
doesn't care as to what goes on behind those method definitions. The
constructor is one of those details it cares not about.
So as long as the simper beans have bean property conformity (eg:
getMyProperty, setMyProperty) then the beans are ready to go with NeXt
as they are wihout mods. I'd be very surprised if it needed mods,
really. You can use Castor types straight up because the properties are
valid bean properties.
A nested bean is simply one object that is returned by the method of
another. As each property getter method has "get" on the front of it,
we're laughin'. At the point of changing a property, you'll need that
"set" on the front of it, naturally. For example, to get the nesting
level deeper in my Monkey examples, I had a "fake" nested property that
returned "this".
eg:
public MonkeyBean getOtherMonkey() { return this; }
To the internals of BeanUtils (the part of Struts that makes it all
happen), it's treated as an entirely different object. It makes no other
assumptions, rightly so. The system is that explicit.
Just give it a bash. Run a simper model through the NeXt tags. I lay my
money on it working as-is.
Arron.
John Menke wrote:
>I'm working through the Simper examples and the NeXt examples and trying to
>understand how I can use both together. Here is what I have so far:
>
>
>In the NeXt you associate nested beans with a parent and children
>relationship by inserting a private member variable to the parent bean the
>will create a new child bean:
>
>ie.
>
><snip - from MonkeyStruts Tutorial>
>
>private BunchBean bunchBean = new BunchBean();
>
>
>This will give us a new instance of the BunchBean when this MonkeyBean is
>created. Just what we want. Now we need to provide the getter method to the
>bean under the property name "pickedBunch". This will create a getter which
>will look something like this example...
>
>Example...
> public BunchBean getPickedBunch() {
> return this.bunchBean;
>
></snip>
>
>This enables you to make forms like this:
>
><snip - from MonkeyStruts Tutorial>
>
><html:form action="/action-tutorial.do">
> Monkey Name: <nested:text property="monkeyName" /><br>
> Monkey Age: <nested:text property="monkeyAge" /><br>
> <br>
> <nested:nest property="pickedBunch">
> Bunch Size: <nested:text property="bunchSize" /><br>
> Bunch Weight: <nested:text property="bunchWeight" /><br>
> Bunch Price: <nested:text property="bunchPrice" /><br>
> </nested:nest>
>
> <br>
> <html:submit>Submit Form</html:submit>
> </html:form>
>
></snip>
>
>In order to use the NeXt with Simper it looks like the SimperBeans will
need
>to include methods like those above in order to establish the relationship.
>
>Is this correct? If so, Simper will not work with the NeXt in it's current
>form.
>
>I think if this can be coded Simper should be able to dynamically update
the
>contents of a database since the nested beans have their Set methods called
>automatically since they are nested within the ActionForm bean? (Aaron is
>this correct?)
>
>Inserts into the database will require creation of a new bean and can be
>handled by logic in the Action that will create a SimperBean with
>information obtained from the ActionForm.
>
>It says in the Simper source code comments that deletes happen
>automatically. I'm not sure at the moment how this is going to work. I
>think you could call the Simper delete method from an Action but not sure
>how the automatic part effects this. Does the automatic feature of deletes
>in Simper just mean that you don't have to call the writechanges() method
in
>Simper?
>
>
>Any comments and additions will be appreciated. In my opinion, the
>integration of these two struts additions could be extremely useful.
>
>Bryan, (If we have to) do you think it's worth adding some code to Simper
to
>integrate with the NeXt?
>
>-john
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>--
>To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
>
--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>