You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Bogdan Calmac <bc...@gmail.com> on 2007/03/24 14:16:15 UTC

T5 - Cancelling a form

What is the recommended way to handle a Cancel button on a form? The
expected behaviour would be to clear the internal state, bypass
validation and move to a different page. I tried:

  @OnEvent(component="Cancel")
  String onCancel()
  {
    surveySession.setSurvey(null);
    return "Start";
  }


where "Cancel" is the id of the submit component but Tapestry
complains that this method cannot return a String:

Event 'selected' from org.byteberry.survey.pages.SurveyDetail:cancel
received an event handler method return value of Start from
org.byteberry.survey.pages.SurveyDetail.onCancel() (at
SurveyDetail.java:46). This type of event does not support return
values from event handler methods.


On the other hand, if I try do do it on the form events I don't know
which button was pressed and I cannot bypass validation.

Is there a straightforward way to do it?

Thanks,

Bogdan Calmac.

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


Re: T5 - Cancelling a form

Posted by Howard Lewis Ship <hl...@gmail.com>.
No, <input type="image"> is not yet supported, but I'm thinking of
adding an image parameter to the Submit component (rather than create
an ImageSubmit component).

On 3/24/07, Bogdan Calmac <bc...@gmail.com> wrote:
> Thanks Howard,
>
> The CSS hack would problably work but I'd rather consider other
> options. I could for instance use some image buttons which have the
> same look and feel for both "Submit" and "Cancel". Does tapestry
> provide the equivalent of <input type="image"> for form submission?
>
>
> Bogdan.
>
> On 3/24/07, Stephan Schwab <sn...@caimito.net> wrote:
> >
> >
> > Howard Lewis Ship wrote:
> > >
> > > How about <a:actionlink t:id="cancel">cancel  ?
> > >
> > > Why should it be necessary to do a form submission, just to discard
> > > all the data in the form?
> > >
> > > If you want, you can use CSS to dress up the link to look like a form
> > > submit button.
> >
> > Right. Actually that's pretty smart and more in compliance with the original
> > idea of the "reset" in pure HTML.
> >
> > Stephan
> > --
> > http://www.stephan-schwab.com
> >
> > --
> > View this message in context: http://www.nabble.com/T5---Cancelling-a-form-tf3458631.html#a9652893
> > Sent from the Tapestry - User mailing list archive at Nabble.com.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

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


Re: T5 - Cancelling a form

Posted by Bogdan Calmac <bc...@gmail.com>.
Thanks Howard,

The CSS hack would problably work but I'd rather consider other
options. I could for instance use some image buttons which have the
same look and feel for both "Submit" and "Cancel". Does tapestry
provide the equivalent of <input type="image"> for form submission?


Bogdan.

On 3/24/07, Stephan Schwab <sn...@caimito.net> wrote:
>
>
> Howard Lewis Ship wrote:
> >
> > How about <a:actionlink t:id="cancel">cancel  ?
> >
> > Why should it be necessary to do a form submission, just to discard
> > all the data in the form?
> >
> > If you want, you can use CSS to dress up the link to look like a form
> > submit button.
>
> Right. Actually that's pretty smart and more in compliance with the original
> idea of the "reset" in pure HTML.
>
> Stephan
> --
> http://www.stephan-schwab.com
>
> --
> View this message in context: http://www.nabble.com/T5---Cancelling-a-form-tf3458631.html#a9652893
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

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


Re: T5 - Cancelling a form

Posted by Stephan Schwab <sn...@caimito.net>.

Howard Lewis Ship wrote:
> 
> How about <a:actionlink t:id="cancel">cancel  ?
> 
> Why should it be necessary to do a form submission, just to discard
> all the data in the form?
> 
> If you want, you can use CSS to dress up the link to look like a form
> submit button.

Right. Actually that's pretty smart and more in compliance with the original
idea of the "reset" in pure HTML.

Stephan
--
http://www.stephan-schwab.com

-- 
View this message in context: http://www.nabble.com/T5---Cancelling-a-form-tf3458631.html#a9652893
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: T5 - Cancelling a form

Posted by Howard Lewis Ship <hl...@gmail.com>.
How about <a:actionlink t:id="cancel">cancel</a> ?

Why should it be necessary to do a form submission, just to discard
all the data in the form?

If you want, you can use CSS to dress up the link to look like a form
submit button.

I think having this cancel feature in T4 was a mistake that caused
more problems than it solved.

On 3/24/07, Stephan Schwab <sn...@caimito.net> wrote:
>
>
>
> Pablo Ruggia wrote:
> >
> > There was a discussion last week on the same topic. Howard said that the
> > best way was to keep a flag like "cancelSelected" and turn it on on the
> > "selected" event. Then in the form "submit" event look to it and do what
> > it
> > needs to do.
> > I think that it is very incovenient, it's a common use case having a lot
> > of
> > buttons, there should be a way to make events from submits button act like
> > listeners in tap4, so they are called at last, when all the form has been
> > processed, so it can redirect to another page.
>
> In my opinion forms should be as simple as possible. From a UI design
> perspective that helps to avoid user confusion. So either you leave a form
> to save the input or you want to abandon it. Leads to only two submit
> buttons.
>
> If you need additional buttons to do additional processing while you are in
> the form, you can always be notified via the OnSelect... callbacks, but you
> should stay in the form and not leave it.
>
> Stephan
> --
> http://www.stephan-schwab.com
>
> --
> View this message in context: http://www.nabble.com/T5---Cancelling-a-form-tf3458631.html#a9651520
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

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


Re: T5 - Cancelling a form

Posted by Stephan Schwab <sn...@caimito.net>.


Pablo Ruggia wrote:
> 
> There was a discussion last week on the same topic. Howard said that the
> best way was to keep a flag like "cancelSelected" and turn it on on the
> "selected" event. Then in the form "submit" event look to it and do what
> it
> needs to do.
> I think that it is very incovenient, it's a common use case having a lot
> of
> buttons, there should be a way to make events from submits button act like
> listeners in tap4, so they are called at last, when all the form has been
> processed, so it can redirect to another page.

In my opinion forms should be as simple as possible. From a UI design
perspective that helps to avoid user confusion. So either you leave a form
to save the input or you want to abandon it. Leads to only two submit
buttons.

If you need additional buttons to do additional processing while you are in
the form, you can always be notified via the OnSelect... callbacks, but you
should stay in the form and not leave it.

Stephan
--
http://www.stephan-schwab.com

-- 
View this message in context: http://www.nabble.com/T5---Cancelling-a-form-tf3458631.html#a9651520
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: T5 - Cancelling a form

Posted by Pablo Ruggia <pr...@gmail.com>.
There was a discussion last week on the same topic. Howard said that the
best way was to keep a flag like "cancelSelected" and turn it on on the
"selected" event. Then in the form "submit" event look to it and do what it
needs to do.
I think that it is very incovenient, it's a common use case having a lot of
buttons, there should be a way to make events from submits button act like
listeners in tap4, so they are called at last, when all the form has been
processed, so it can redirect to another page.

On 3/24/07, Bogdan Calmac <bc...@gmail.com> wrote:
>
> What is the recommended way to handle a Cancel button on a form? The
> expected behaviour would be to clear the internal state, bypass
> validation and move to a different page. I tried:
>
>   @OnEvent(component="Cancel")
>   String onCancel()
>   {
>     surveySession.setSurvey(null);
>     return "Start";
>   }
>
>
> where "Cancel" is the id of the submit component but Tapestry
> complains that this method cannot return a String:
>
> Event 'selected' from org.byteberry.survey.pages.SurveyDetail:cancel
> received an event handler method return value of Start from
> org.byteberry.survey.pages.SurveyDetail.onCancel() (at
> SurveyDetail.java:46). This type of event does not support return
> values from event handler methods.
>
>
> On the other hand, if I try do do it on the form events I don't know
> which button was pressed and I cannot bypass validation.
>
> Is there a straightforward way to do it?
>
> Thanks,
>
> Bogdan Calmac.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>