You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Radim Burget <Ra...@seznam.cz> on 2005/07/31 14:10:13 UTC

Validation - newbie question

Hi,
(just newbie)
I need a "datePicker" and validate input as required field with 
"dateValidator". Is it possible?

Many thanks for any help.
Radim
--------------------------
Separatelly I have manneged both:
1] date picker:

<bean name="stringValidator" class="net.sf.tapestry.valid.StringValidator" lifecycle="page">
  		<set-property name="required" expression="true"/>
  		<set-property name="clientScriptingEnabled" expression="true"/>
</bean>

2] dateValidator:

<bean name="dateValidator" class="net.sf.tapestry.valid.DateValidator" lifecycle="page">
  		<set-property name="required" expression="true"/>
  		<set-property name="clientScriptingEnabled" expression="true"/>
</bean>

<component id="dateOfBirth" type="ValidField">
	<binding name="value" expression="visit.dateOfBirth"/>
    <binding name="validator" expression='beans.dateValidator'/>
    <static-binding name="displayName">Date of birth</static-binding>
</component>


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


RE: Validation - newbie question

Posted by Patrick Casey <pa...@adelphia.net>.
	You need to specify a date format to get the date validator to work.

<bean name="dateTimeValidator"
class="org.apache.tapestry.valid.DateValidator">
        <set-property name="Format"
expression="visit.currentUser.dateTimeFormat" />
    </bean>

<component id="exit" type="ValidField">
        <binding name="value" expression="object.exit"/>
        <binding name="validator" expression="beans.dateTimeValidator"/>
        <static-binding name="displayName" value="Date Exited:"/>
    </component>

	The Format property uses the standard java date format strings e.g.
"MM/dd/yy HH:mm:ss".

	If you want every user to potentially have a different date format
it's a good idea to derive your date format from your user object, even if
it's just a stub method that returns a static. That way if you ever need to
internationalize you'll have the infrastructure in place.

	You could, of course, specify a litteral, but then you're just
buying yourself some pain later on when i18n pops up.

	--- Pat
> -----Original Message-----
> From: Radim Burget [mailto:RadimBurget@seznam.cz]
> Sent: Sunday, July 31, 2005 5:10 AM
> To: tapestry-user@jakarta.apache.org
> Subject: Validation - newbie question
> 
> Hi,
> (just newbie)
> I need a "datePicker" and validate input as required field with
> "dateValidator". Is it possible?
> 
> Many thanks for any help.
> Radim
> --------------------------
> Separatelly I have manneged both:
> 1] date picker:
> 
> <bean name="stringValidator" class="net.sf.tapestry.valid.StringValidator"
> lifecycle="page">
>   		<set-property name="required" expression="true"/>
>   		<set-property name="clientScriptingEnabled"
> expression="true"/>
> </bean>
> 
> 2] dateValidator:
> 
> <bean name="dateValidator" class="net.sf.tapestry.valid.DateValidator"
> lifecycle="page">
>   		<set-property name="required" expression="true"/>
>   		<set-property name="clientScriptingEnabled"
> expression="true"/>
> </bean>
> 
> <component id="dateOfBirth" type="ValidField">
> 	<binding name="value" expression="visit.dateOfBirth"/>
>     <binding name="validator" expression='beans.dateValidator'/>
>     <static-binding name="displayName">Date of birth</static-binding>
> </component>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org



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