I'd warn against using persistent ID objects as keys for edit forms.
The problem is that Tapestry persists properties on a page/session key. So
for any given session, page "foo" has a set of persistent properties.

        Lets say though that you have a page called "editUser".

        You have a list of users.
        User clicks open in new tab on bob. 
        editUser -> Bob opens up. Key = Bob
        User clicks open in new tab on ted.
        editUser -> ted opesns up. Key = Ted.
        User update's bob's entry. 
        User presses save.
        Ted's record just got updated.

        The solution turns out to be stuffing the edited in the form via a
hidden field. Stuff it on "top" of the form so it bootstraps the record
during rewind just like you're doing, but don't trust the page to persist it
for you; send it out with the form so you can guarantee it comes back with
the form.

        --- Pat

> -----Original Message-----
> From: Steven Wisener [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, July 19, 2005 7:26 PM
> To: Tapestry users; Jer Kah
> Subject: Re: how to persist id parameter?
> 
> I think he got that far...the problem is posting back to the form. I
> made the ID property persistent to solve the problem (it is stored in
> the session, so it won't be null on the second page render), but you
> should be able to use a Hidden component as well:
> 
> In your form, add:
> 
> <span jwcid="@Hidden" value="ognl:id" listener="ognl:listeners.initObject"
> />
> 
> If the rest of the components rely on the object being initialized,
> make sure it appears first in the form. Your page class should look
> something like this:
> 
> public void pageBeginRender(PageEvent event) {
>     if (getId() != null) {
>         initObject(event.getRequestCycle());
>     }
> }
> 
> public void initObject(IRequestCycle cycle) {
>     setObject(getObjectFromDatabase(getId());
> }
> 
> So here's the basic flow: The first time the page is loaded, the id
> property is set and initObject loads it. When the form is submitted,
> the id is not set yet in pageBeginRender, so initObject is not called.
> When the render hits the Hidden component however, initObject is
> called because it is its listener method. As long as you only need the
> object loaded after the Hidden component is rendered in the rewind,
> you should be golden. I haven't actually tested this out yet, but I
> think it should work.
> 
> --Steven
> 
> 
> 
> 
> On 7/7/05, Jer Kah <[EMAIL PROTECTED]> wrote:
> > Your html should be something like:
> >
> > <span  jwcid="@DirectLink"listener="ognl:listeners.edit"
> > parameters="ognl:currentItem.ID" >edit</span>
> >
> > This calls the "edit" listener method.  Inside that method, grab the
> > parameter and bucket brigade it to the Edit page.
> >   public void edit(IRequestCycle cycle)
> >   {
> >
> >     Object[] params = cycle.getServiceParameters();
> >     int id= ((Integer) params[0]).intValue();
> >
> >     EditPage nextPage =  (EditPage ) cycle.getPage("EditPage");
> >     nextPage .setID(id);
> >     cycle.activate(nextPage );
> >   }
> >
> >
> > Then the ID should be available in the pageBeginRender method on the
> > Edit page by calling getID()
> >
> > Hope that helps.
> >
> >
> >
> >
> >
> > On 7/7/05, Jeff Emminger <[EMAIL PROTECTED]> wrote:
> > > apologies for a probably simple question:
> > >
> > > i have my List page use a DirectLink to send to an Edit page with the
> id
> > > of the object clicked as a parameter.
> > >
> > > the Edit page picks this id up in pageBeginRender() from
> > > getServiceParameters() and loads the appropriate object.
> > >
> > > the problem is when i post back, that parameter is no longer in
> > > getServiceParameters()... is there a standard way to do this?
> > >
> > >
> > > ---------------------------------------------------------------------
> > > 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]
> >
> >
> 
> ---------------------------------------------------------------------
> 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]

Reply via email to