On 1/12/06, Richard Clark <[EMAIL PROTECTED]> wrote: > > Basically, you don't want to have the form work directly against your > object. > > Copy out all of the data you care about into individual getters/ > setters (so, for a typical address you'd have get/set address, get/ > set city, etc.), and load the data from your object into these using > a pageBeginRender method. Also store the object's database ID in a > hidden field. > > On submit, fetch the object from the database, then get each of the > things you set at the start, write the changes into the object, then > save it. > > Alternately, copy the original object into a scratch object, then > extract the data from the scratch object on submit. > > ...Richard
Hi, Is this approach most common? What are alternatives? Max/ On Jan 11, 2006, at 16:12, Ted Steen wrote: > > > Hi all! > > > > Hibernate problem ahead... > > > > I want to have a form that allows me to alter a certian object. the > > form should use validation, so if something goes wrong I want to be > > able to correct the mistake and be able to press save again. I don`t > > want the changes to persist until the validation succeeds. > > > > When the page gets attached I load the object O by calling > > MyDAO.getMyObject(..); > > this method is intercepted and a transaction is wrapped around the > > call. > > > > After this (if save was pressed), Tapestry gets all POST data and > > updates O with the new values. > > Note that the altering of O is done outside a transaction! I know that > > this is not good, but the alternative would be to wrap it in a > > transaction, and thus commiting the changes.. which I don`t want to do > > until I have done the final validation in my listener. Then and only > > then I want to explicitly persist the changes. > > > > I guess that working with the same object over different transactions > > is considered a bad thing.. but how should it be done otherwise? > > > > One thought I had was to set O on a Tapestry persisted method (using > > @Persist) the first time I get to the page. and then work with that > > and finally when I want to persist the object attach it to the session > > (using session.lock(...)) and then session.merge(...); > > > > > > Everything else works just fine. I use HibernateSqueezer which works > > brilliant. and I intercept all my DAO:s methods. the persistent layer > > is _almost_ transparent... it`s just this little "update problem" > > that`s still bugging me.. > > > > Thanks! > > /ted > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
