You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Leszek Gawron <ou...@wlkp.org> on 2003/07/31 17:00:54 UTC
Woody complex multipaged form
I've send this to dev@cocoon as it contains some ideas about Woody multipage
forms
* INTRODUCTION *
****************
Consider such case:
You have a form for inputting report parameters. It goes something like this:
----------------------------------------------------------------------------
Please input all report parameters blah blah:
Customer code : _________________________ *pick*
Start date : _________________________ *pick*
End date : _________________________ *pick*
Ordering : ______________________\/_
-----------
- Submit -
-----------
A little description:
1. Customer code
you need a valid customer code here. There are a lot customer codes (for
example 10'000). In my xml form description (which is later on rendered to
html via a stylesheet) I have introduced specialized input type called
"picker" which renders as a readonly edit box and a button. When *pick* button
is pressed:
1. a popup window opens which contains a form with query parameters
2. I can query a customer
3. get a list of first XXX results
4. pick a customer by clicking a table row
5. the above causes to fill-in the edit box with a valid customer code and the
popup closes automatically
2. Start and end date
I have introduced a JavaScript based calendar ( <div> shown in an absolute
position) so now:
1. I do not need to worry that the date is invalid
2. the form looks really sexy :)
* GOAL *
********
I'd like to achieve the same/similar functionality with Woody without too much
effort.
So first:
1. Can I implement a widget that is not a standard one (a customer/product
picker, date picker)?
2. Can I render it my way without rewriting the whole woody stylesheet? (I
think not).
Big question now:
3. Some users hate popup windows (me too). So I'd like to migrate to flow
based approach and after customer picker button is pressed a query page is
opened but IN THE SAME WINDOW. After picking a customer the flow goes back to
main form. As far as I understand Woody builds it's model basing on request
parameters (I do not get the whole binding concept right now so please correct
me). How can I store the main form data until flow gets back to it? Let me
remind you that the purpose of this whole thing is to write a bunch of reports
so I really do not want to write a bean for each report I implement.
A nice approach would be :
1. Display a report form and allow user to edit data.
2. When a picker is pressed the whole form is stored (with no bean and stuff -
just the whole form) somewhere in the session context under "form_name"
3. Picker is displayed
4. If picker is submitted - some of picker model data is rewritten to a main
model
5. Main report is displayed again.
what do you think about all that?
LG
Re: Woody complex multipaged form
Posted by Bruno Dumon <br...@outerthought.org>.
On Thu, 2003-07-31 at 17:00, Leszek Gawron wrote:
<snip use case/>
>
> * GOAL *
> ********
> I'd like to achieve the same/similar functionality with Woody without too much
> effort.
>
> So first:
> 1. Can I implement a widget that is not a standard one (a customer/product
> picker, date picker)?
yes you can, but I don't see why it's needed here. The only thing you
need is a combination of the 'outputfield' widget (being discussed but
not yet implemented) combined with the button widget.
> 2. Can I render it my way without rewriting the whole woody stylesheet? (I
> think not).
Just create a new XSL, import the woody.xsl, and add a template to
render your new widget.
>
> Big question now:
> 3. Some users hate popup windows (me too). So I'd like to migrate to flow
> based approach and after customer picker button is pressed a query page is
> opened but IN THE SAME WINDOW. After picking a customer the flow goes back to
> main form. As far as I understand Woody builds it's model basing on request
> parameters (I do not get the whole binding concept right now so please correct
> me).
The binding is a completely optional feature of Woody. If you don't want
to load/store data to/from beans or XML documents, then you don't need
it.
> How can I store the main form data until flow gets back to it?
Just keep a reference to the form. All data is stored in the form.
The current flowscript integration is somewhat centered around one-form
handling. You'll need to write your own entrypoint instead of relying on
the 'woody' function.
I have never tried this, but this should be the basic outline:
cocoon.load("resource://org/apache/cocoon/woody/flow/javascript/woody.js");
function myapp() {
var mainForm = new Form("path/to/formdefinitionfile.xml");
var somePickerForm =
new Form("path/to/anotherformdefinitionfile.xml");
mainForm.show("mainform-display-pipeline", formHandler);
}
function formHandler(form) {
switch(form.getSubmitId()) {
case "goto-picker":
{
somePickerForm.show(...);
mainForm.getModel().myfield =
somePickerForm.getModel().somefield;
}
break;
}
}
The above code assumes that your button to navigate to the picker has
its action-command set to 'goto-picker'.
The myapp function is the one to call from the sitemap.
> Let me
> remind you that the purpose of this whole thing is to write a bunch of reports
> so I really do not want to write a bean for each report I implement.
Woody doesn't require you to write a bean, all the forms data is stored
in its own form object model.
>
> A nice approach would be :
> 1. Display a report form and allow user to edit data.
> 2. When a picker is pressed the whole form is stored (with no bean and stuff -
> just the whole form) somewhere in the session context under "form_name"
see above, you don't need to store it in the session, it can simply be
stored in a variable in your flowscript. Actually, using the session
limits you to one interaction with the user, since there's only one
session per user, while you can have many flow-instances.
> 3. Picker is displayed
> 4. If picker is submitted - some of picker model data is rewritten to a main
> model
> 5. Main report is displayed again.
>
Hope this helps,
Bruno
--
Bruno Dumon http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org bruno@apache.org