On Wed, 27 Jul 2011 10:19:18 -0300, George Christman <gchrist...@cardaddy.com> wrote:

opps my save is backwards in my previous example

@CommitAfter
@OnEvent(value = EventConstants.SELECTED, component = "update")
Object updatePurchaseRequest() {
      purchaseRequestState.setPurchaseRequest(getPurchaseRequest());
      return formZone.getBody();
}

@OnEvent(value = EventConstants.SELECTED, component = "save")
Object savePurchaseRequest() { // or any other name
      session.saveOrUpdate(getPurchaseRequest());
      return
 pageRenderLinkSource.createPageRenderLinkWithContext(Update.class,
 getPurchaseRequest().getId());
}

You can also rewrite the method above in a simpler, more refactory-safe manner:

@InjectPage
private Update update;

@OnEvent(value = EventConstants.SELECTED, component = "save")
Object savePurchaseRequest() { // or any other name
      session.saveOrUpdate(getPurchaseRequest());
      update.setPurchaseRequest(getPurchaseRequest());
      return update;
}

In your Update page class, you should need to add this (very recommended for any page with activation context anyway)

Object onPassivate() {
        Object value = null;
        if (purchaseRequest != null) {
                value = purchaseRequest.getId();
        }
        return value;
}

This supposes the Update page class has a purchaseRequest property.

--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to