You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Simon Raveh <sr...@gmail.com> on 2006/06/21 07:18:09 UTC

Client side validation and Form

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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Client side validation and Form

Posted by Shing Hing Man <ma...@yahoo.com>.
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="title@TextField"
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 <sr...@gmail.com> wrote:

> Do you mind posting an example, here is the way I
> tried using it
> 
> <td><input type="submit" class="button"
> value="&larr; Back" 
> onclick="document.form.elements.cancel"> &nbsp;
> <input type=submit 
> class="button" value="Login &rarr;"></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 <sr...@gmail.com> 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:
> >> users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail:
> >> users-help@tapestry.apache.org
> >>
> >>
> >>     
> >
> > 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:
> users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail:
> users-help@tapestry.apache.org
> 
> 

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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Client side validation and Form

Posted by Simon Raveh <sr...@gmail.com>.
Do you mind posting an example, here is the way I tried using it

<td><input type="submit" class="button" value="&larr; Back" 
onclick="document.form.elements.cancel"> &nbsp; <input type=submit 
class="button" value="Login &rarr;"></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 <sr...@gmail.com> 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:
>> users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail:
>> users-help@tapestry.apache.org
>>
>>
>>     
>
> 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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Form action problem in embedded form

Posted by Jimmi Dyson <ji...@lawton.co.uk>.
Hello,

I have a form embedded in a component that is then used on multiple
pages. The form gets rendered correctly, but the action HTML parameter
does not get set - well, it gets set to the path to the page. Here's
some source:

PollModuleComponent.java:
...
@Component(type = "Form", bindings = "listener = listener:submitPoll")
public abstract Form getPollForm();

public void submitPoll() {
        ...
}

If I change the listener:submitPoll to anything else (even
wibble:hello), there is no exception thrown as I would expect.

It's like it's just ignoring the listener binding in an embedded form.

Any ideas anyone?

Cheers,
Jimmi


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


Re: Client side validation and Form

Posted by Shing Hing Man <ma...@yahoo.com>.
> 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 <sr...@gmail.com> 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:
> users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail:
> users-help@tapestry.apache.org
> 
> 

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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org