You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by David Mann <Da...@invera.com> on 2003/11/20 23:33:12 UTC

Patterns for common use case set of List items, create item, upd ate item

I have a common pattern of displaying a list of objects, each with a link to
a form for editing.  Often the list would have additional actions such as
navigation, create new, ....

While it seems straightforward, I have found the appropriate code patterns
difficult to pin down. Here's my patterns with which I get painted into a
corner.  Any experience coders, please advise.

The query list [component] paints using @ForEach with a collection
instantiated through the navigation submit button listeners (firstAction,
nextAction, ...), or in the case of the first access...

  public void pageBeginRender(PageEvent event) {
    log.info(event);
    IEngineService service = event.getRequestCycle().getService();

       // @TODO Yuck, read the documentation and
	 // and find out how to treat that first get
       if (service instanceof PageService) {
         firstAction(event.getRequestCycle());
       }			
    }

which works ok as the submits are fired off of DirectService [PATTERN ONE
anybody?].

Each detail line uses a stateless DirectLink for the selection of a detail,
basically do little for now, just activation of the form for the query
page...

  public void viewAction(IRequestCycle requestCycle) {

    // Irrelevant stuff, maybe we should go
    // straight to form with PageLinks
    requestCycle.activate(formIPage);
  }

Ok, but I don't really need to bother the QueryPage, but DirectLink is so
handy [PATTERN TWO anybody?]

Finally the real mess, how to handle the rendering of the form.  When are we
rendering from a drill in from the query list (requires initialization of
the target object), versus when are we rendering
from a Form button action event (submit for update, or other use case ...).
I can't use the service trick in pattern one as all actions are direct.  The
first time in, pageBeginRender has my service parameters, but after looking
at the trace (annotated)...

16062 INFO  [PoolThread-1] pages.ExpenseReportForm::pageBeginRender -
Service Parameter, object id
16078 INFO  [PoolThread-1] pages.ExpenseReportForm::pageBeginRender -
Rewinding: false

Ok form shows our object ! Let's update using a @Submit

18437 INFO  [PoolThread-1] pages.ExpenseReportForm::pageBeginRender - Not My
Service Parameter - 0
18437 INFO  [PoolThread-1] pages.ExpenseReportForm::pageBeginRender -
Rewinding: true

Aha rewinding, no need to get object yet 

18469 INFO  [PoolThread-1] pages.ExpenseReportForm::updateAction - Errors:
true

Some validation errors reported, no update yet but....

18437 INFO  [PoolThread-1] pages.ExpenseReportForm::pageBeginRender - Not My
Service Parameter - 0
18469 INFO  [PoolThread-1] pages.ExpenseReportForm::pageBeginRender -
Rewinding: false

Another render, how do I know not to go fetch the object again, and what
about these service parameters.

Ok, I'm stumped.  What's the basic pattern for a List, Create, Update set of
use cases ?

David Mann (newbie)
Montreal


****************************************************************************

This e-mail may be privileged and/or confidential, and the sender does not
waive any related rights and obligations. Any distribution, use or copying
of this e-mail or the information it contains by other than an intended
recipient is unauthorized. If you received this e-mail in error, please
advise me (by return e-mail or otherwise) immediately. 

Ce courriel est confidentiel et protégé. L'expéditeur ne renonce pas aux
droits et obligations qui s'y rapportent. Toute diffusion, utilisation ou
copie de ce message ou des renseignements qu'il contient par une personne
autre que le (les) destinataire(s) désigné(s) est interdite. Si vous recevez
ce courriel par erreur, veuillez m'en aviser immédiatement, par retour de
courriel ou par un autre moyen.

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