You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jan Vissers <Ja...@cumquat.nl> on 2008/04/15 19:34:01 UTC

How to 'bypass' client side validation - when 'Cancel' is pressed.

I'm getting the hang of it --- and liking it!

Yet another question;
How can I bypass normal client side validation, in case I have a form
that includes a 'Cancel' button. Currently I need to enter something
valid before I can 'Cancel' my action - not really what I want ;-)

-J.


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


Re: How to 'bypass' client side validation - when 'Cancel' is pressed.

Posted by Davor Hrg <hr...@gmail.com>.
after client validation is skipped,
you have to catch the selected event from that button
and clear validation errors on form


something like this:

public void onSelectedFromCancel(){
    _form.clearErrors();
}

Davor Hrg

On Fri, Apr 18, 2008 at 9:28 AM, Jan Vissers <Ja...@cumquat.nl> wrote:

> Using this script - indeed skips client side validation.
> However when I come back to the form - the respective fields are (still)
> marked as erroneous. Any way around that?
>
> -J.
>
> On Tue, 2008-04-15 at 20:38 +0200, Davor Hrg wrote:
> > you can do it with javascript... sth like this (not tested)
> >
> > put a normal
> > <input type="submit" value="${cancel}" onclick="return
> > avoidValidation(this)">
> >
> >
> > function avoidValidation(elem){
> >     var form = elem.parentNode;
> >     //find form
> >     while(form && form.tagName != "FORM") form = form.parentNode;
> >     form.onsubmit = null;
> >     return true;
> > }
> >
> > I've added a jira for this some time ago ... and it got prolonged to
> T5.1
> > somehow :(
> >
> > https://issues.apache.org/jira/browse/TAPESTRY-2109
> >
> >
> >
> >
> > On Tue, Apr 15, 2008 at 7:35 PM, Filip S. Adamsen <fs...@fsadev.com>
> wrote:
> >
> > > There is no way to do this as far as I know. I believe the current
> > > workaround is to create an action link styled as a button and do
> whatever
> > > needs doing there.
> > >
> > > -Filip
> > >
> > >
> > > On 2008-04-15 19:34, Jan Vissers wrote:
> > >
> > > > I'm getting the hang of it --- and liking it!
> > > >
> > > > Yet another question;
> > > > How can I bypass normal client side validation, in case I have a
> form
> > > > that includes a 'Cancel' button. Currently I need to enter something
> > > > valid before I can 'Cancel' my action - not really what I want ;-)
> > > >
> > > > -J.
> > > >
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > 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
> > >
> > >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Antwort: Re: How to 'bypass' client side validation - when 'Cancel' is pressed.

Posted by Christian Koeberl <ch...@porsche.co.at>.
> However when I come back to the form - the respective fields are (still)
> marked as erroneous. Any way around that?
This is related to this issue: 
https://issues.apache.org/jira/browse/TAPESTRY-2354
I think this is fixed in the trunk - or at least you can specify the 
persistence scope of the ValidationTracker.

A workaround for older versions is described here:
http://www.nabble.com/Writing-an-FAQ-for-Tapestry-5-tt15719185.html#a15732836

> Using this script - indeed skips client side validation.
I would rather use an ActionLink or PageLink and style it or use the 
Button component form T5Components 
(http://87.193.218.134:8080/t5components/t5c-commons/ref/org/apache/tapestry/commons/components/Button.html).

-- 
Chris

Re: How to 'bypass' client side validation - when 'Cancel' is pressed.

Posted by Jan Vissers <Ja...@cumquat.nl>.
Using this script - indeed skips client side validation.
However when I come back to the form - the respective fields are (still)
marked as erroneous. Any way around that?

-J.

On Tue, 2008-04-15 at 20:38 +0200, Davor Hrg wrote:
> you can do it with javascript... sth like this (not tested)
> 
> put a normal
> <input type="submit" value="${cancel}" onclick="return
> avoidValidation(this)">
> 
> 
> function avoidValidation(elem){
>     var form = elem.parentNode;
>     //find form
>     while(form && form.tagName != "FORM") form = form.parentNode;
>     form.onsubmit = null;
>     return true;
> }
> 
> I've added a jira for this some time ago ... and it got prolonged to T5.1
> somehow :(
> 
> https://issues.apache.org/jira/browse/TAPESTRY-2109
> 
> 
> 
> 
> On Tue, Apr 15, 2008 at 7:35 PM, Filip S. Adamsen <fs...@fsadev.com> wrote:
> 
> > There is no way to do this as far as I know. I believe the current
> > workaround is to create an action link styled as a button and do whatever
> > needs doing there.
> >
> > -Filip
> >
> >
> > On 2008-04-15 19:34, Jan Vissers wrote:
> >
> > > I'm getting the hang of it --- and liking it!
> > >
> > > Yet another question;
> > > How can I bypass normal client side validation, in case I have a form
> > > that includes a 'Cancel' button. Currently I need to enter something
> > > valid before I can 'Cancel' my action - not really what I want ;-)
> > >
> > > -J.
> > >
> > >
> > > ---------------------------------------------------------------------
> > > 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
> >
> >


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


Re: How to 'bypass' client side validation - when 'Cancel' is pressed.

Posted by Marcus <mv...@gmail.com>.
Hi Jan,

maybe this help

<t:form t:id="cancelForm">
    <t:submit value="Cancel">
</t:form>

void onSubmitFromCancelForm() { ... }


Marcus

Re: How to 'bypass' client side validation - when 'Cancel' is pressed.

Posted by Davor Hrg <hr...@gmail.com>.
you are right :)

I saw some crossbrowser code that assumed input.form is not
always available ... I haven't looked into the reasons for it.

On Tue, Apr 15, 2008 at 9:06 PM, Andreas Andreou <an...@gmail.com> wrote:

> not true, even IE4 had this - it's also extensively used in T4.1
>
> But your code is good when you start from any given dom node, i.e. a link
> and not just an input control
>
> On Tue, Apr 15, 2008 at 9:55 PM, Davor Hrg <hr...@gmail.com> wrote:
> > that does not work for all browsers as far as I know... :)
> >  I can't remember which any more...
> >  but try it out in IE and FF, I think one of them does not support it
> :(:(
> >
> >  Davor Hrg
> >
> >
> >
> >  On Tue, Apr 15, 2008 at 8:51 PM, Andreas Andreou <an...@gmail.com>
> wrote:
> >
> >  > fyi, you can get to the form easier (assuming you're in a form
> control)
> >  > with
> >  > var form = elem.form
> >  >
> >  > On Tue, Apr 15, 2008 at 9:38 PM, Davor Hrg <hr...@gmail.com>
> wrote:
> >  > > you can do it with javascript... sth like this (not tested)
> >  > >
> >  > >  put a normal
> >  > >  <input type="submit" value="${cancel}" onclick="return
> >  > >  avoidValidation(this)">
> >  > >
> >  > >
> >  > >  function avoidValidation(elem){
> >  > >     var form = elem.parentNode;
> >  > >     //find form
> >  > >     while(form && form.tagName != "FORM") form = form.parentNode;
> >  > >     form.onsubmit = null;
> >  > >     return true;
> >  > >  }
> >  > >
> >  > >  I've added a jira for this some time ago ... and it got prolonged
> to
> >  > T5.1
> >  > >  somehow :(
> >  > >
> >  > >  https://issues.apache.org/jira/browse/TAPESTRY-2109
> >  > >
> >  > >
> >  > >
> >  > >
> >  > >
> >  > >
> >  > >  On Tue, Apr 15, 2008 at 7:35 PM, Filip S. Adamsen <fs...@fsadev.com>
> >  > wrote:
> >  > >
> >  > >  > There is no way to do this as far as I know. I believe the
> current
> >  > >  > workaround is to create an action link styled as a button and do
> >  > whatever
> >  > >  > needs doing there.
> >  > >  >
> >  > >  > -Filip
> >  > >  >
> >  > >  >
> >  > >  > On 2008-04-15 19:34, Jan Vissers wrote:
> >  > >  >
> >  > >  > > I'm getting the hang of it --- and liking it!
> >  > >  > >
> >  > >  > > Yet another question;
> >  > >  > > How can I bypass normal client side validation, in case I have
> a
> >  > form
> >  > >  > > that includes a 'Cancel' button. Currently I need to enter
> >  > something
> >  > >  > > valid before I can 'Cancel' my action - not really what I want
> ;-)
> >  > >  > >
> >  > >  > > -J.
> >  > >  > >
> >  > >  > >
> >  > >  > >
> >  > ---------------------------------------------------------------------
> >  > >  > > 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
> >  > >  >
> >  > >  >
> >  > >
> >  >
> >  >
> >  >
> >  > --
> >  > Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
> >  > Tapestry / Tacos developer
> >  > Open Source / JEE Consulting
> >  >
> >  > ---------------------------------------------------------------------
> >  > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >  > For additional commands, e-mail: users-help@tapestry.apache.org
> >  >
> >  >
> >
>
>
>
> --
> Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
> Tapestry / Tacos developer
> Open Source / JEE Consulting
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: How to 'bypass' client side validation - when 'Cancel' is pressed.

Posted by Andreas Andreou <an...@gmail.com>.
not true, even IE4 had this - it's also extensively used in T4.1

But your code is good when you start from any given dom node, i.e. a link
and not just an input control

On Tue, Apr 15, 2008 at 9:55 PM, Davor Hrg <hr...@gmail.com> wrote:
> that does not work for all browsers as far as I know... :)
>  I can't remember which any more...
>  but try it out in IE and FF, I think one of them does not support it :(:(
>
>  Davor Hrg
>
>
>
>  On Tue, Apr 15, 2008 at 8:51 PM, Andreas Andreou <an...@gmail.com> wrote:
>
>  > fyi, you can get to the form easier (assuming you're in a form control)
>  > with
>  > var form = elem.form
>  >
>  > On Tue, Apr 15, 2008 at 9:38 PM, Davor Hrg <hr...@gmail.com> wrote:
>  > > you can do it with javascript... sth like this (not tested)
>  > >
>  > >  put a normal
>  > >  <input type="submit" value="${cancel}" onclick="return
>  > >  avoidValidation(this)">
>  > >
>  > >
>  > >  function avoidValidation(elem){
>  > >     var form = elem.parentNode;
>  > >     //find form
>  > >     while(form && form.tagName != "FORM") form = form.parentNode;
>  > >     form.onsubmit = null;
>  > >     return true;
>  > >  }
>  > >
>  > >  I've added a jira for this some time ago ... and it got prolonged to
>  > T5.1
>  > >  somehow :(
>  > >
>  > >  https://issues.apache.org/jira/browse/TAPESTRY-2109
>  > >
>  > >
>  > >
>  > >
>  > >
>  > >
>  > >  On Tue, Apr 15, 2008 at 7:35 PM, Filip S. Adamsen <fs...@fsadev.com>
>  > wrote:
>  > >
>  > >  > There is no way to do this as far as I know. I believe the current
>  > >  > workaround is to create an action link styled as a button and do
>  > whatever
>  > >  > needs doing there.
>  > >  >
>  > >  > -Filip
>  > >  >
>  > >  >
>  > >  > On 2008-04-15 19:34, Jan Vissers wrote:
>  > >  >
>  > >  > > I'm getting the hang of it --- and liking it!
>  > >  > >
>  > >  > > Yet another question;
>  > >  > > How can I bypass normal client side validation, in case I have a
>  > form
>  > >  > > that includes a 'Cancel' button. Currently I need to enter
>  > something
>  > >  > > valid before I can 'Cancel' my action - not really what I want ;-)
>  > >  > >
>  > >  > > -J.
>  > >  > >
>  > >  > >
>  > >  > >
>  > ---------------------------------------------------------------------
>  > >  > > 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
>  > >  >
>  > >  >
>  > >
>  >
>  >
>  >
>  > --
>  > Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
>  > Tapestry / Tacos developer
>  > Open Source / JEE Consulting
>  >
>  > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>  > For additional commands, e-mail: users-help@tapestry.apache.org
>  >
>  >
>



-- 
Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

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


Re: How to 'bypass' client side validation - when 'Cancel' is pressed.

Posted by Davor Hrg <hr...@gmail.com>.
that does not work for all browsers as far as I know... :)
I can't remember which any more...
but try it out in IE and FF, I think one of them does not support it :(:(

Davor Hrg

On Tue, Apr 15, 2008 at 8:51 PM, Andreas Andreou <an...@gmail.com> wrote:

> fyi, you can get to the form easier (assuming you're in a form control)
> with
> var form = elem.form
>
> On Tue, Apr 15, 2008 at 9:38 PM, Davor Hrg <hr...@gmail.com> wrote:
> > you can do it with javascript... sth like this (not tested)
> >
> >  put a normal
> >  <input type="submit" value="${cancel}" onclick="return
> >  avoidValidation(this)">
> >
> >
> >  function avoidValidation(elem){
> >     var form = elem.parentNode;
> >     //find form
> >     while(form && form.tagName != "FORM") form = form.parentNode;
> >     form.onsubmit = null;
> >     return true;
> >  }
> >
> >  I've added a jira for this some time ago ... and it got prolonged to
> T5.1
> >  somehow :(
> >
> >  https://issues.apache.org/jira/browse/TAPESTRY-2109
> >
> >
> >
> >
> >
> >
> >  On Tue, Apr 15, 2008 at 7:35 PM, Filip S. Adamsen <fs...@fsadev.com>
> wrote:
> >
> >  > There is no way to do this as far as I know. I believe the current
> >  > workaround is to create an action link styled as a button and do
> whatever
> >  > needs doing there.
> >  >
> >  > -Filip
> >  >
> >  >
> >  > On 2008-04-15 19:34, Jan Vissers wrote:
> >  >
> >  > > I'm getting the hang of it --- and liking it!
> >  > >
> >  > > Yet another question;
> >  > > How can I bypass normal client side validation, in case I have a
> form
> >  > > that includes a 'Cancel' button. Currently I need to enter
> something
> >  > > valid before I can 'Cancel' my action - not really what I want ;-)
> >  > >
> >  > > -J.
> >  > >
> >  > >
> >  > >
> ---------------------------------------------------------------------
> >  > > 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
> >  >
> >  >
> >
>
>
>
> --
> Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
> Tapestry / Tacos developer
> Open Source / JEE Consulting
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: How to 'bypass' client side validation - when 'Cancel' is pressed.

Posted by Andreas Andreou <an...@gmail.com>.
fyi, you can get to the form easier (assuming you're in a form control) with
var form = elem.form

On Tue, Apr 15, 2008 at 9:38 PM, Davor Hrg <hr...@gmail.com> wrote:
> you can do it with javascript... sth like this (not tested)
>
>  put a normal
>  <input type="submit" value="${cancel}" onclick="return
>  avoidValidation(this)">
>
>
>  function avoidValidation(elem){
>     var form = elem.parentNode;
>     //find form
>     while(form && form.tagName != "FORM") form = form.parentNode;
>     form.onsubmit = null;
>     return true;
>  }
>
>  I've added a jira for this some time ago ... and it got prolonged to T5.1
>  somehow :(
>
>  https://issues.apache.org/jira/browse/TAPESTRY-2109
>
>
>
>
>
>
>  On Tue, Apr 15, 2008 at 7:35 PM, Filip S. Adamsen <fs...@fsadev.com> wrote:
>
>  > There is no way to do this as far as I know. I believe the current
>  > workaround is to create an action link styled as a button and do whatever
>  > needs doing there.
>  >
>  > -Filip
>  >
>  >
>  > On 2008-04-15 19:34, Jan Vissers wrote:
>  >
>  > > I'm getting the hang of it --- and liking it!
>  > >
>  > > Yet another question;
>  > > How can I bypass normal client side validation, in case I have a form
>  > > that includes a 'Cancel' button. Currently I need to enter something
>  > > valid before I can 'Cancel' my action - not really what I want ;-)
>  > >
>  > > -J.
>  > >
>  > >
>  > > ---------------------------------------------------------------------
>  > > 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
>  >
>  >
>



-- 
Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

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


Re: How to 'bypass' client side validation - when 'Cancel' is pressed.

Posted by Davor Hrg <hr...@gmail.com>.
you can do it with javascript... sth like this (not tested)

put a normal
<input type="submit" value="${cancel}" onclick="return
avoidValidation(this)">


function avoidValidation(elem){
    var form = elem.parentNode;
    //find form
    while(form && form.tagName != "FORM") form = form.parentNode;
    form.onsubmit = null;
    return true;
}

I've added a jira for this some time ago ... and it got prolonged to T5.1
somehow :(

https://issues.apache.org/jira/browse/TAPESTRY-2109




On Tue, Apr 15, 2008 at 7:35 PM, Filip S. Adamsen <fs...@fsadev.com> wrote:

> There is no way to do this as far as I know. I believe the current
> workaround is to create an action link styled as a button and do whatever
> needs doing there.
>
> -Filip
>
>
> On 2008-04-15 19:34, Jan Vissers wrote:
>
> > I'm getting the hang of it --- and liking it!
> >
> > Yet another question;
> > How can I bypass normal client side validation, in case I have a form
> > that includes a 'Cancel' button. Currently I need to enter something
> > valid before I can 'Cancel' my action - not really what I want ;-)
> >
> > -J.
> >
> >
> > ---------------------------------------------------------------------
> > 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: How to 'bypass' client side validation - when 'Cancel' is pressed.

Posted by "Filip S. Adamsen" <fs...@fsadev.com>.
There is no way to do this as far as I know. I believe the current 
workaround is to create an action link styled as a button and do 
whatever needs doing there.

-Filip

On 2008-04-15 19:34, Jan Vissers wrote:
> I'm getting the hang of it --- and liking it!
> 
> Yet another question;
> How can I bypass normal client side validation, in case I have a form
> that includes a 'Cancel' button. Currently I need to enter something
> valid before I can 'Cancel' my action - not really what I want ;-)
> 
> -J.
> 
> 
> ---------------------------------------------------------------------
> 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