cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jason Johnston" <>
Subject Re: Multi-page form not keeping state
Date Wed, 05 Oct 2005 17:58:14 GMT
> I have an odd problem with a multi-page form.
> Page one shows a single integer field with validation, a "next" button
and a
> "cancel" button.
> Page two,three,four,five, and six all show a bunch of booleanfields.
> Depending on what value I put in the field on page1, one of the other 5
pages will be displayed.
> The problem is:
> When the form is displayed and the integer field is filled-in and the
user presses "next", the next page is properly displayed. BUT, if the
user presses the browser's Back button (showing the first page again),
then clicks the "next" button again, the form is dismissed and the
original Flow
> continues.

Here's where I see a red flag.  I'm not sure how using the browser Back
button in this setup would display the first screen again, unless it's
just being redisplayed from the browser's cache.  Once your "next" action
widget is invoked the first time, the internal state of the Form object is
changed, and using the browser Back button will not change that internal
state back.

So what's happening in this flow is:

1) Your "next" button is pressed and the attached handler is executed; its
parent is set to INVISIBLE and the appropriate sibling is set to ACTIVE.
2) You hit the browser Back button, which redisplays the page (from the
browser cache?) but the section being displayed is still INVISIBLE in the
Form model.
3) Your "next" button is pressed again in the browser, but now the Form
model ignores that invokation because it is INVISIBLE.
4) The form continues to be processed normally *for the current state it
is in*, which only has one of the booleanfields section as ACTIVE.  If
there is no extra validation for this "page" of booleanfields, the form
will think it succeeded validation and exit the form.showForm() loop,
continuing the flow.

Does that help explain the behavior you're seeing?  I don't have an easy
answer on how to get around the problem, but perhaps understanding how
things are working will give you some guidance on how to architect your

I think I've seen a few questions on the list recently about using the
browser Back button and CForms.  Perhaps the docs should be clearer about
how the CForms flow handles Back button functionality (for the most part,
it doesn't!)

> Here's the action. I put a debug println in there to see if it was
getting called the 2nd time, and its NOT. It only gets called the first
time the action occurs.
> Can anyone help with this?
> <fd:action id="next" action-command="foo">
>     <fd:label><i18n:text i18n:key="next"/></fd:label>
>     <fd:on-action>
>         <fd:javascript>
>             java.lang.System.err.println("Here");
>             var parent = event.source.parent;
>             if (parent.validate()) {
>                 parent.setState(WidgetState.INVISIBLE);
>                 var imp =
> parseInt(event.source.parent.lookupWidget("dre").getValue());
>                 if (imp == 0) {
> parent.lookupWidget("../cat1").setState(WidgetState.ACTIVE);
>                 } else if (imp > 4 &amp;&amp; imp &lt; 8) {
> parent.lookupWidget("../cat2").setState(WidgetState.ACTIVE);
>                 } else if (imp > 14 &amp;&amp; imp &lt; 19) {
> parent.lookupWidget("../cat3").setState(WidgetState.ACTIVE);
>                 } else if (imp > 24 &amp;&amp; imp &lt; 29) {
> parent.lookupWidget("../cat4").setState(WidgetState.ACTIVE);
>                 } else {
> parent.lookupWidget("../cat5").setState(WidgetState.ACTIVE);
>                 }
>             }
>         </fd:javascript>
>     </fd:on-action>
> </fd:action>

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message