Please see my below example.
Shing
Java file :
import org.apache.tapestry.IRequestCycle;
public abstract class TestValidateNumber extends
BasePage {
public abstract double getNumber();
public abstract void setNumber(double num);
public abstract String getTitle();
public abstract void setTitle(String str);
public void submitForm(IRequestCycle cycle){
System.out.println(" number =" + getNumber() +
"\n title =" + getTitle());
}
public void cancelForm(IRequestCycle cycle){
System.out.println(" Cancelle ---");
}
=============
TestValidateNumber.page :
<?xml version="1.0"?>
<!DOCTYPE page-specification PUBLIC
"-//Apache Software Foundation//Tapestry
Specification 4.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
<page-specification
class="man.pages.validateInput.TestValidateNumber" >
<bean name="delegate"
class="org.apache.tapestry.valid.ValidationDelegate"/>
<component id="form" type="Form">
<binding name="listener"
value="listener:submitForm"/>
<binding name="delegate" value="beans.delegate"/>
<binding name="clientValidationEnabled"
value="ognl:true"/>
<binding name="cancel"
value="listener:cancelForm"/>
</component>
<component id="numberTF" type="TextField">
<binding name="value" value="number"/>
<binding name="translator"
value="translator:number,pattern=#.#"/>
<binding name="validators"
value="validators:required"/>
<binding name="displayName" value="literal:Input
number"/>
</component>
<component id="numberLabel" type="FieldLabel">
<binding name="field"
value="component:numberTF"/>
</component>
<component id="errors" type="Delegator">
<binding name="delegate"
value="ognl:beans.delegate.firstError"/>
</component>
<component id="hasError" type="If">
<binding name="condition"
value="ognl:beans.delegate.hasErrors" />
</component>
</page-specification>
==================
TestValidateNumber.html :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN
"http://www.w3.org/TR/html4/loose.dtd"">
<html jwcid="@Shell" title="TestValidateNumber(Tap
4)">
<body jwcid="@Body" >
<div align="center"><h1>An example on validating a
number</h1> </div>
<span jwcd="hasError">
<div style="color:red">
<span jwcid="errors" />
</div>
</span>
<form jwcid="form" >
<span jwcid="numberLabel"/>: <input type="text"
jwcid="numberTF" /> <br>
<span jwcid="@FieldLabel"
field="component:title" displayName="Title" />
<input jwcid="[EMAIL PROTECTED]"
validators="validators:required"
displayName="Title" value="ognl:title" type="text" />
<input type="submit" value="cancel"
onclick="document.form.events.cancel()"/>
<input type="submit" />
</form>
============= end =============
--- Simon Raveh <[EMAIL PROTECTED]> wrote:
> Do you mind posting an example, here is the way I
> tried using it
>
> <td><input type="submit" class="button"
> value="← Back"
> onclick="document.form.elements.cancel">
> <input type=submit
> class="button" value="Login →"></td>
>
> and the form component
>
> <component id="form" type="Form">
> <binding name="success"
> value="listener:checkToken"/>
> <binding name="stateful" value="false"/>
> <binding name="clientValidationEnabled"
> value="true"/>
> <binding name="cancel"
> value="listener:logout"/>
> </component>
>
> The logout method was never called
>
> Thanks,
>
> Simon
>
> Shing Hing Man wrote:
> >> I tried canceling the form using
> >> document.form.events.cancel as it shows
> >> in the form component document but this doesn't
> >>
> >
> >
> > That's strange. The cancel parameter in the Form
> > component works for me.
> >
> > Shing
> >
> > --- Simon Raveh <[EMAIL PROTECTED]> wrote:
> >
> >
> >> Hi,
> >>
> >> I have a simple form with two submit components.
> >> The first one (Revert) should revert and take the
> >> user back, the second
> >> one (Save) save the changes.
> >> I have client side validation enabled.
> >> My problem is that I want to validate the input
> only
> >> if the user click
> >> on the submit component that save the changes and
> >> not when the user
> >> decided to revert.
> >> Is there a way to tell Tapestry to bypass client
> >> side validation.
> >> I tried canceling the form using
> >> document.form.events.cancel as it shows
> >> in the form component document but this doesn't
> >> work.
> >>
> >> Thanks,
> >> Simon
> >>
> >>
> >>
> >
>
---------------------------------------------------------------------
> >
> >> To unsubscribe, e-mail:
> >> [EMAIL PROTECTED]
> >> For additional commands, e-mail:
> >> [EMAIL PROTECTED]
> >>
> >>
> >>
> >
> > Home page :
> > http://uk.geocities.com/matmsh/index.html
> >
> >
> >
> >
>
___________________________________________________________
>
> > To help you stay safe and secure online, we've
> developed the all new Yahoo! Security Centre.
> http://uk.security.yahoo.com
> >
> >
> `
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
>
>
Home page :
http://uk.geocities.com/matmsh/index.html
___________________________________________________________
To help you stay safe and secure online, we've developed the all new Yahoo!
Security Centre. http://uk.security.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]