cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Per Kreipke" <...@onclave.com>
Subject RE: [Q] Form posting sitemap pattern...
Date Wed, 04 Sep 2002 21:49:23 GMT
Lajos,

Wow. Very concise, thanks.

So, the tricks I missed were:

- nesting the validate action and the insert action, I had put them together
in an action-set instead. I actually knew better but that was dumb.

- [here's the kicker] the validator action gets called both when posting
_and_ when simply displaying the form.

- actions without any sub components to execute are pure code and can
actually 'populate' your pipeline (e.g. the way the validator stores stuff).
That's a _very_ handy trick. Will come in handy for setting request
params/globals.

Will try immediately,

Per

> Hi Per -
>
> If you were using the formval logicsheet and the FormValidatorAction,
> you'd have something like this:
>
>   <map:match pattern="newbook">
>    <map:act type="form-validator">
>     <map:parameter name="descriptor"
>       value="context://newbook-def.xml"/>
>     <map:parameter name="validate-set" value="add"/>
>
>     <map:act type="db-insert">
>      <map:parameter name="descriptor"
>       value="context://newbook-def.xml"/>
>      <map:redirect-to uri="books"/>
>     </map:act>
>    </map:act>
>    <map:generate type="serverpages" src="addbook.xsp"/>
>    <map:transform src="addbook.xsl"/>
>    <map:serialize/>
>   </map:match>
>
> Here, the "newbook" pipeline is the action for your form and "books" is
> the pipeline for the display of books (not shown). When the "newbook"
> pipeline executes, the action "validator" tries to validate the posted
> form. If nothing was posted, or if the validation failed, execution
> drops outside that <map:act> block to the "addbook.xsp" page, which
> contains your form and which uses the formval logicsheet to access info
> on what failed during validation. If validation succeeds, then
> everything inside that <map:act> block gets executed which, as you can
> see, uses the DatabaseAddAction to insert the row in your database and
> then redirects the user to the "books" pipeline. Key to the
> DatabaseAddAction, FormValidatorAction and formval logicsheet is the
> descriptor file "newbook-def.xml". All these concepts are discussed in
> the Cocoon documentation.
>
> The main gotcha here is the formval logicsheet is a bit clumsy to use,
> as you have to make sure you not only display validation errors to the
> user, but repopulate valid fields with the data the user already entered.
>
> Regards,
>
> Lajos
>
> galatea.com
> Cocoon training, consulting & support
>
>
> Per Kreipke wrote:
>
> > I can't quite figure out what the right way is to use actions to handle
> > posting when there is an originating page, the form itself, a
> validator and
> > an action.
> >
> > Scenario:
> >
> > - The user has a page which displays a collection of items of some sort
> > (books).
> >   + page: books.xyz
> >
> > - clicking 'new' on the books page brings up a form for entering a new
> > book's details
> >   + page: newbook.xyz
> >
> > - posting the book's details should validate the book's details
> (must have a
> > title)
> >   + validator action: ValidateBook.java
> >
> > - Code adds the book to the book repository
> >   + add action: AddBook.java
> >
> >
> > Flows:
> >
> > books.xyz -> [new book] -> newbook.xyz -> [post]
> > 	-> ValidateBook -> [ok] -> AddBook -> books.xyz
> >
> >
> > books.xyz -> [new book] -> newbook.xyz -> [post]
> > 	-> ValidateBook -> [fail] -> newbook.xyz
> >
> >
> > Details:
> >
> > - to implement both flows above, I can't figure out what:
> >   + the 'action' target of the POST should be: books.xyz again,
> newbook.xyz?
> >   + what matcher to put the validate and add actions on
> >
> > Any help would be appreciated. A pointer to or an actual sample sitemap
> > snippet would be great.
> >
> > FYI, I'm not using XMLForm and I'm using 2.0.3
> >
> > Per
> >
> >
> > ---------------------------------------------------------------------
> > Please check that your question  has not already been answered in the
> > FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
> >
> > To unsubscribe, e-mail:     <cocoon-users-unsubscribe@xml.apache.org>
> > For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>
> >
> >
>
>
> --
>
>
>
>
> ---------------------------------------------------------------------
> Please check that your question  has not already been answered in the
> FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
>
> To unsubscribe, e-mail:     <cocoon-users-unsubscribe@xml.apache.org>
> For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>
>
>


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>


Mime
View raw message