You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Dan Diephouse <da...@envoisolutions.com> on 2005/09/16 21:00:07 UTC

Database Update Cycle

Howdy,
I'm using T4 and a bit confused about how to create update screens. Let 
me explain. I have a User class which I pull from the database. I have a 
form which updates to properties (of many) on the User object: login and 
password.

When I first click on "edit user" I have a edit() function which 
populates MyPage.user from the database.  I have a save() method which 
is triggered by a button on the edit form. When I click save() I want to 
pull the User from the DB and then have the login/password fields 
updated on that User object. But Tapestry always wants to create the 
User object itself via ognl it seems.

How can I get it from the DB on the update?

Thanks,

- Dan


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


Re: Database Update Cycle

Posted by Tomáš Drenčák <to...@gmail.com>.
I use hibernate pojo objects as entities. So in edit listener I
populate object from database and set it in persistent property on
edit page. Every field component (e.g. login, password) is attached
directly to entity object's property with value biding so after update
there's changed entity object in persistent property and could be
saved into database.

2005/9/16, Dan Diephouse <da...@envoisolutions.com>:
> Howdy,
> I'm using T4 and a bit confused about how to create update screens. Let
> me explain. I have a User class which I pull from the database. I have a
> form which updates to properties (of many) on the User object: login and
> password.
> 
> When I first click on "edit user" I have a edit() function which
> populates MyPage.user from the database.  I have a save() method which
> is triggered by a button on the edit form. When I click save() I want to
> pull the User from the DB and then have the login/password fields
> updated on that User object. But Tapestry always wants to create the
> User object itself via ognl it seems.
> 
> How can I get it from the DB on the update?
> 
> Thanks,
> 
> - Dan
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
>

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


Re: Database Update Cycle

Posted by Jun Tsai <ju...@gmail.com>.
Can you show your CayennedataSqueezer?
I want to do it for hibernate.thanks.

On 9/17/05, Nick Stuart <ba...@gmail.com> wrote:
> I personally go with Tomáš' approach as its really easy. :)
> The other approach, that may or may not be 'more' correct is to make a
> custom data squeezer that will transform your primary keys to objects
> and vice versa for form use.
> 
> For example, I made a CayenneDataSqueezer that could take any of my
> DataObjects and put them into the form with having to have the value
> persistent, and I could use it where ever I wanted and not have to
> worry about writing get/set methods every where.
> 
> If you want some example code let me know.
> 
> -Nick
> 
> On 9/16/05, Dan Diephouse <da...@envoisolutions.com> wrote:
> > Thanks Patrick! Someone should put this in the FAQ :-)
> > 
> > - Dan
> > 
> > Patrick Casey wrote:
> > >       Put a hidden text field at the *top* of your form so it rewinds
> > > first. Put the unique ID of your persistent object there.
> > >
> > >       Bind that field do a property on your form.
> > >
> > >       In that property's setter method, load your object.
> > >
> > >       --- Pat
> > >
> > >
> > >>-----Original Message-----
> > >>From: news [mailto:news@sea.gmane.org] On Behalf Of Dan Diephouse
> > >>Sent: Friday, September 16, 2005 12:00 PM
> > >>To: tapestry-user@jakarta.apache.org
> > >>Subject: Database Update Cycle
> > >>
> > >>Howdy,
> > >>I'm using T4 and a bit confused about how to create update screens. Let
> > >>me explain. I have a User class which I pull from the database. I have a
> > >>form which updates to properties (of many) on the User object: login and
> > >>password.
> > >>
> > >>When I first click on "edit user" I have a edit() function which
> > >>populates MyPage.user from the database.  I have a save() method which
> > >>is triggered by a button on the edit form. When I click save() I want to
> > >>pull the User from the DB and then have the login/password fields
> > >>updated on that User object. But Tapestry always wants to create the
> > >>User object itself via ognl it seems.
> > >>
> > >>How can I get it from the DB on the update?
> > >>
> > >>Thanks,
> > >>
> > >>- Dan
> > >>
> > >>
> > >>---------------------------------------------------------------------
> > >>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > >>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> > >
> > >
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> > >
> > >
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> > 
> >
> 


-- 
Welcome to China Java Users Group(CNJUG).
http://cnjug.dev.java.net

Re: Database Update Cycle

Posted by Nick Stuart <ba...@gmail.com>.
I personally go with Tomáš' approach as its really easy. :)
The other approach, that may or may not be 'more' correct is to make a
custom data squeezer that will transform your primary keys to objects
and vice versa for form use.

For example, I made a CayenneDataSqueezer that could take any of my
DataObjects and put them into the form with having to have the value
persistent, and I could use it where ever I wanted and not have to
worry about writing get/set methods every where.

If you want some example code let me know.

-Nick

On 9/16/05, Dan Diephouse <da...@envoisolutions.com> wrote:
> Thanks Patrick! Someone should put this in the FAQ :-)
> 
> - Dan
> 
> Patrick Casey wrote:
> >       Put a hidden text field at the *top* of your form so it rewinds
> > first. Put the unique ID of your persistent object there.
> >
> >       Bind that field do a property on your form.
> >
> >       In that property's setter method, load your object.
> >
> >       --- Pat
> >
> >
> >>-----Original Message-----
> >>From: news [mailto:news@sea.gmane.org] On Behalf Of Dan Diephouse
> >>Sent: Friday, September 16, 2005 12:00 PM
> >>To: tapestry-user@jakarta.apache.org
> >>Subject: Database Update Cycle
> >>
> >>Howdy,
> >>I'm using T4 and a bit confused about how to create update screens. Let
> >>me explain. I have a User class which I pull from the database. I have a
> >>form which updates to properties (of many) on the User object: login and
> >>password.
> >>
> >>When I first click on "edit user" I have a edit() function which
> >>populates MyPage.user from the database.  I have a save() method which
> >>is triggered by a button on the edit form. When I click save() I want to
> >>pull the User from the DB and then have the login/password fields
> >>updated on that User object. But Tapestry always wants to create the
> >>User object itself via ognl it seems.
> >>
> >>How can I get it from the DB on the update?
> >>
> >>Thanks,
> >>
> >>- Dan
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
>

Re: Database Update Cycle

Posted by Dan Diephouse <da...@envoisolutions.com>.
Thanks Patrick! Someone should put this in the FAQ :-)

- Dan

Patrick Casey wrote:
> 	Put a hidden text field at the *top* of your form so it rewinds
> first. Put the unique ID of your persistent object there.
> 
> 	Bind that field do a property on your form.
> 
> 	In that property's setter method, load your object.
> 
> 	--- Pat
> 
> 
>>-----Original Message-----
>>From: news [mailto:news@sea.gmane.org] On Behalf Of Dan Diephouse
>>Sent: Friday, September 16, 2005 12:00 PM
>>To: tapestry-user@jakarta.apache.org
>>Subject: Database Update Cycle
>>
>>Howdy,
>>I'm using T4 and a bit confused about how to create update screens. Let
>>me explain. I have a User class which I pull from the database. I have a
>>form which updates to properties (of many) on the User object: login and
>>password.
>>
>>When I first click on "edit user" I have a edit() function which
>>populates MyPage.user from the database.  I have a save() method which
>>is triggered by a button on the edit form. When I click save() I want to
>>pull the User from the DB and then have the login/password fields
>>updated on that User object. But Tapestry always wants to create the
>>User object itself via ognl it seems.
>>
>>How can I get it from the DB on the update?
>>
>>Thanks,
>>
>>- Dan
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


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


RE: Database Update Cycle

Posted by Patrick Casey <pa...@adelphia.net>.
	Put a hidden text field at the *top* of your form so it rewinds
first. Put the unique ID of your persistent object there.

	Bind that field do a property on your form.

	In that property's setter method, load your object.

	--- Pat

> -----Original Message-----
> From: news [mailto:news@sea.gmane.org] On Behalf Of Dan Diephouse
> Sent: Friday, September 16, 2005 12:00 PM
> To: tapestry-user@jakarta.apache.org
> Subject: Database Update Cycle
> 
> Howdy,
> I'm using T4 and a bit confused about how to create update screens. Let
> me explain. I have a User class which I pull from the database. I have a
> form which updates to properties (of many) on the User object: login and
> password.
> 
> When I first click on "edit user" I have a edit() function which
> populates MyPage.user from the database.  I have a save() method which
> is triggered by a button on the edit form. When I click save() I want to
> pull the User from the DB and then have the login/password fields
> updated on that User object. But Tapestry always wants to create the
> User object itself via ognl it seems.
> 
> How can I get it from the DB on the update?
> 
> Thanks,
> 
> - Dan
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org




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