You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Jeremy Quinn <je...@media.demon.co.uk> on 2003/11/06 14:23:06 UTC

[Woody] cancel button

Hi All,

I am trying to add a 'Cancel' button to a form, so if the user clicks 
it they exit the current form processing by being redirected to another 
URL, it is not working as expected.

in my form model:

<wd:action id="cancel" action-command="cancel">
   <wd:label>Cancel</wd:label>
   <wd:hint>cancels this form</wd:hint>
   <wd:on-action>
     <javascript>cancel();</javascript>
   </wd:on-action>
</wd:action>

in my form template:

<wt:widget id="cancel"/>

in my flowscript:

function cancel () {
   cocoon.sendPage("screen/cancel", {message: "You cancelled"});
   cocoon.log.info ("The user Cancelled");
}

When I click the 'Cancel' button, I am returned to the form, instead of 
being redirected to the cancel screen, even though the log.info message 
appears.

Have I misunderstood something?

Thanks for any help

regards Jeremy


Re: [Woody] cancel button

Posted by Jeremy Quinn <je...@media.demon.co.uk>.
On 6 Nov 2003, at 18:24, Sylvain Wallez wrote:

> Jeremy Quinn wrote:
>
>>
>> On Thursday, November 6, 2003, at 01:34 PM, Reinhard Poetz wrote:
>>
>>>
>>> From: Jeremy Quinn
>>>
>>>> Hi All,
>>>>
>>>> I am trying to add a 'Cancel' button to a form, so if the user 
>>>> clicks
>>>> it they exit the current form processing by being redirected
>>>> to another
>>>> URL, it is not working as expected.
>>>>
>>
>> <snip/>
>>
>>> I guess it is a problem that currently happens following:
>>> If you hit the cancel button, the JS cancel function is executed - 
>>> also
>>> the sendPage function is called. But then some CPU cycles later the
>>> woody function is called and it calls sendPageAndWait with the 
>>> current
>>> form as content. ... and as you may expect the latter wins ...
>>>
>>> I think we have to make sure that always sendPage* the first call is
>>> preferred.
>>
>>
>> OK, I think I have solved it .....
>>
>> My form flowscript:
>>
>>     . . .
>>     form.showForm (formURI);
>>     if ("cancel".equals (form.getWidget().getSubmitWidget().getId 
>> ())) {
>>         cocoon.sendPage("screen/cancel", {message: "You cancelled"});
>>         return;
>>     }
>>     . . .
>>
>> The cancel function:
>>
>> function cancel (form) {
>>     form.endProcessing (false);
>>     cocoon.log.info ("The user Cancelled");
>> }
>>
>> The form Model:
>>
>> <wd:action id="cancel" action-command="cancel">
>>     <wd:label>Cancel</wd:label>
>>     <wd:hint>cancels the current action</wd:hint>
>>     <wd:on-action>
>>         <javascript>
>>             cancel(event.getSourceWidget().getForm());
>>         </javascript>
>>     </wd:on-action>
>> </wd:action>
>>
>> Phew!! :)
>>
> Or more simply:
>
> <wd:submit id="cancel" validate="false"> (a submit doesn't redisplay 
> the form, while an action always redisplays it)
>
> and in the flowscript :
>
> form.showForm("form.html");
> if (form.submitId == cancel) {
>  cocoon.sendPage("cancel.html");
> }
>
> ;-)

That IS simpler !!!

Many Thanks

regards Jeremy

------------------------------------------------------------------------
"Objective reality is a synthetic construct, dealing with a 
hypothetical universalization of a multitude of subjective realities."
Philip K Dick - "The Electric Ant"


Re: [Woody] cancel button

Posted by Sylvain Wallez <sy...@apache.org>.
Jeremy Quinn wrote:

>
> On Thursday, November 6, 2003, at 01:34 PM, Reinhard Poetz wrote:
>
>>
>> From: Jeremy Quinn
>>
>>> Hi All,
>>>
>>> I am trying to add a 'Cancel' button to a form, so if the user clicks
>>> it they exit the current form processing by being redirected
>>> to another
>>> URL, it is not working as expected.
>>>
>
> <snip/>
>
>> I guess it is a problem that currently happens following:
>> If you hit the cancel button, the JS cancel function is executed - also
>> the sendPage function is called. But then some CPU cycles later the
>> woody function is called and it calls sendPageAndWait with the current
>> form as content. ... and as you may expect the latter wins ...
>>
>> I think we have to make sure that always sendPage* the first call is
>> preferred.
>
>
> OK, I think I have solved it .....
>
> My form flowscript:
>
>     . . .
>     form.showForm (formURI);
>     if ("cancel".equals (form.getWidget().getSubmitWidget().getId ())) {
>         cocoon.sendPage("screen/cancel", {message: "You cancelled"});
>         return;
>     }
>     . . .
>
> The cancel function:
>
> function cancel (form) {
>     form.endProcessing (false);
>     cocoon.log.info ("The user Cancelled");
> }
>
> The form Model:
>
> <wd:action id="cancel" action-command="cancel">
>     <wd:label>Cancel</wd:label>
>     <wd:hint>cancels the current action</wd:hint>
>     <wd:on-action>
>         <javascript>
>             cancel(event.getSourceWidget().getForm());
>         </javascript>
>     </wd:on-action>
> </wd:action>
>
> Phew!! :)
>
Or more simply:

<wd:submit id="cancel" validate="false"> (a submit doesn't redisplay the 
form, while an action always redisplays it)

and in the flowscript :

form.showForm("form.html");
if (form.submitId == cancel) {
  cocoon.sendPage("cancel.html");
}

;-)

Sylvain


-- 
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }
Orixo, the opensource XML business alliance  -  http://www.orixo.com



Re: [Woody] cancel button

Posted by Jeremy Quinn <je...@media.demon.co.uk>.
On Thursday, November 6, 2003, at 01:34 PM, Reinhard Poetz wrote:

>
> From: Jeremy Quinn
>
>> Hi All,
>>
>> I am trying to add a 'Cancel' button to a form, so if the user clicks
>> it they exit the current form processing by being redirected
>> to another
>> URL, it is not working as expected.
>>

<snip/>

> I guess it is a problem that currently happens following:
> If you hit the cancel button, the JS cancel function is executed - also
> the sendPage function is called. But then some CPU cycles later the
> woody function is called and it calls sendPageAndWait with the current
> form as content. ... and as you may expect the latter wins ...
>
> I think we have to make sure that always sendPage* the first call is
> preferred.

OK, I think I have solved it .....

My form flowscript:

	. . .
	form.showForm (formURI);
	if ("cancel".equals (form.getWidget().getSubmitWidget().getId ())) {
		cocoon.sendPage("screen/cancel", {message: "You cancelled"});
		return;
	}
	. . .

The cancel function:

function cancel (form) {
	form.endProcessing (false);
	cocoon.log.info ("The user Cancelled");
}

The form Model:

<wd:action id="cancel" action-command="cancel">
	<wd:label>Cancel</wd:label>
	<wd:hint>cancels the current action</wd:hint>
	<wd:on-action>
		<javascript>
			cancel(event.getSourceWidget().getForm());
		</javascript>
	</wd:on-action>
</wd:action>

Phew!! :)

Thanks

regards Jeremy


RE: [Woody] cancel button

Posted by Reinhard Poetz <re...@apache.org>.
From: Jeremy Quinn
 
> Hi All,
> 
> I am trying to add a 'Cancel' button to a form, so if the user clicks 
> it they exit the current form processing by being redirected 
> to another 
> URL, it is not working as expected.
> 
> in my form model:
> 
> <wd:action id="cancel" action-command="cancel">
>    <wd:label>Cancel</wd:label>
>    <wd:hint>cancels this form</wd:hint>
>    <wd:on-action>
>      <javascript>cancel();</javascript>
>    </wd:on-action>
> </wd:action>
> 
> in my form template:
> 
> <wt:widget id="cancel"/>
> 
> in my flowscript:
> 
> function cancel () {
>    cocoon.sendPage("screen/cancel", {message: "You cancelled"});
>    cocoon.log.info ("The user Cancelled");
> }
> 
> When I click the 'Cancel' button, I am returned to the form, 
> instead of 
> being redirected to the cancel screen, even though the 
> log.info message 
> appears.
> 
> Have I misunderstood something?

I guess it is a problem that currently happens following: 
If you hit the cancel button, the JS cancel function is executed - also
the sendPage function is called. But then some CPU cycles later the
woody function is called and it calls sendPageAndWait with the current
form as content. ... and as you may expect the latter wins ...

I think we have to make sure that always sendPage* the first call is
preferred.

Cheers,
Reinhard