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]

Reply via email to