You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Gareth Lloyd <gj...@cox.net> on 2004/04/28 03:56:43 UTC

domain objects with tapestry

hello,
i've been struggling to understand a few basic things about tapestry, 
mainly centered around how to use domain objects with the framework.

it seems that the BasePage classes are very close to a POJO (plain old 
java object) entity object (object with just setters and getters).. but 
its different enough so that you still need you entity objects as 
another class.

for instance, say you have an Employee object with attributes of 
lastName, firstName, salary, etc.. and a bunch of public getters and 
setters... how do you 'hook' up a tapestry form to this object... from 
all the examples i've seen, it seems you have to dupicate all the 
setters and getters (albiet as abstract) in a BasePage object...? this 
seems like a lot of duplciated effort. Am i missing something here? how 
would  you create a simple 'edit employee' form, that maps to a simple 
Employee object.. i've searched high and low for this very simple 
example, but have found none (even bought the book Tapestry in Action)..

please help!

thanks
G

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


Re: domain objects with tapestry

Posted by Vjeran Marcinko <vj...@tis.hr>.
----- Original Message ----- 
From: "Glen Stampoultzis" <gs...@iinet.net.au>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Wednesday, April 28, 2004 6:38 AM
Subject: Re: domain objects with tapestry


> At 12:11 PM 28/04/2004, you wrote:
> You might want to avoid changing an object that's attached to a
> hibernate
> session until you're sure you want to commit.

That's exactly what happened to me the other day. I wasn't supose to allow
this persistent page variable to change due to form submission until I know
that update to database where it was extracted from initially hasn't gone
well. So I needed to use copy of this persistent object for form. It seems
that statefulness comes with a price sometimes ;-)

-Vjeran


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


Re: domain objects with tapestry

Posted by Glen Stampoultzis <gs...@iinet.net.au>.
At 12:11 PM 28/04/2004, you wrote:
>Just hold the employee domain object itself as _one_ property of your page 
>class. Then your page template for example can reference employee 
>properties via OGNL expressions like:
>   ognl:employee.lastName
>
>Very simple... There's really no reason or advantage in duplicating all 
>the employee fields in your page class.

There are a few reason why you might want to have an extra level of 
indirection.

You might want to transform certain feeds before displaying them.
You might want to avoid changing an object that's attached to a hibernate 
session until you're sure you want to commit.
Your page layout could be significantly different than the domain object.

Also worth being aware that persistent properties only get persisted if the 
value or reference get's modified.  That means if you have a persistent 
domain object and change it's internal members that tapestry isn't going to 
know it's been updated.  This might be another reason to use a level of 
indirection.

The choice depends on what you're trying to do.

Regards,


Glen Stampoultzis
gstamp@iinet.net.au
http://members.iinet.net.au/~gstamp/glen/

Re: domain objects with tapestry

Posted by Colin Sampaleanu <co...@exis.com>.
Gareth,

Just hold the employee domain object itself as _one_ property of your 
page class. Then your page template for example can reference employee 
properties via OGNL expressions like:
   ognl:employee.lastName

Very simple... There's really no reason or advantage in duplicating all 
the employee fields in your page class.

Regards,
Colin


Gareth Lloyd wrote:

> hello,
> i've been struggling to understand a few basic things about tapestry, 
> mainly centered around how to use domain objects with the framework.
>
> it seems that the BasePage classes are very close to a POJO (plain old 
> java object) entity object (object with just setters and getters).. 
> but its different enough so that you still need you entity objects as 
> another class.
>
> for instance, say you have an Employee object with attributes of 
> lastName, firstName, salary, etc.. and a bunch of public getters and 
> setters... how do you 'hook' up a tapestry form to this object... from 
> all the examples i've seen, it seems you have to dupicate all the 
> setters and getters (albiet as abstract) in a BasePage object...? this 
> seems like a lot of duplciated effort. Am i missing something here? 
> how would  you create a simple 'edit employee' form, that maps to a 
> simple Employee object.. i've searched high and low for this very 
> simple example, but have found none (even bought the book Tapestry in 
> Action)..
>
> please help!
>
> thanks
> G




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