Re: Textfield validation problem
Change this: binding name=translator value=translator:number,pattern=#.#/ to this: binding name=translator value=translator:number,pattern=#.#,omitZero=false/ The 'omitZero' property in org.apache.tapestry.form.translator.NumberTranslator is true by default. Paul Ferraro (who I believe contributed much of the translation and validation system for Tap 4.0) argues that omitZero should be false by default in this JIRA issue: http://issues.apache.org/jira/browse/TAPESTRY-633 So vote for it if you agree. -Ryan On Oct 14, 2006, at 11:44 AM, Jabbar wrote: Oops. The textfield component definition is component id=dailyHighThreshold type=TextField binding name=value value=currentChannelSetup.dailyThreshold.highThresholdDouble/ binding name=translator value=translator:number,pattern=#.#/ binding name=validators value=validators:required[You must enter {0}!], min=0/ binding name=displayName value=literal:Daily High Threshold/ binding name=disabled value=!currentChannelSetup.dailyThreshold.dailyThresholdEnabled/ /component On 14/10/06, Jabbar [EMAIL PROTECTED] wrote: Hello again, I have another problem. It concerns the textfield the definition is component id=dailyHighThreshold type=TextField binding name=value value=currentChannelSetup.dailyThreshold.highThresholdDouble/ !-- binding name=translator value=translator:number,pattern=#.#/ binding name=validators value=validators:required[You must enter {0}!], min=0/ binding name=displayName value=literal:Daily High Threshold/ -- binding name=disabled value=!currentChannelSetup.dailyThreshold.dailyThresholdEnabled/ /component when value is numeric 0 then the textfield also shows a blank. I don't understand this! Anybody got any ideas? -- Thanks A Jabbar Azam -- Thanks A Jabbar Azam - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Ryan Holmes, CISSP [EMAIL PROTECTED] ph. (213) 626-0026 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Textfield validation problem
Ryan, Hello again. Is it possible to use a regular expression with a textfield? I don't want to use it to read a number, but a string. Thanks On 14/10/06, Ryan Holmes [EMAIL PROTECTED] wrote: Change this: binding name=translator value=translator:number,pattern=#.#/ to this: binding name=translator value=translator:number,pattern=#.#,omitZero=false/ The 'omitZero' property in org.apache.tapestry.form.translator.NumberTranslator is true by default. Paul Ferraro (who I believe contributed much of the translation and validation system for Tap 4.0) argues that omitZero should be false by default in this JIRA issue: http://issues.apache.org/jira/browse/TAPESTRY-633 So vote for it if you agree. -Ryan On Oct 14, 2006, at 11:44 AM, Jabbar wrote: Oops. The textfield component definition is component id=dailyHighThreshold type=TextField binding name=value value=currentChannelSetup.dailyThreshold.highThresholdDouble/ binding name=translator value=translator:number,pattern=#.#/ binding name=validators value=validators:required[You must enter {0}!], min=0/ binding name=displayName value=literal:Daily High Threshold/ binding name=disabled value=!currentChannelSetup.dailyThreshold.dailyThresholdEnabled/ /component On 14/10/06, Jabbar [EMAIL PROTECTED] wrote: Hello again, I have another problem. It concerns the textfield the definition is component id=dailyHighThreshold type=TextField binding name=value value=currentChannelSetup.dailyThreshold.highThresholdDouble/ !-- binding name=translator value=translator:number,pattern=#.#/ binding name=validators value=validators:required[You must enter {0}!], min=0/ binding name=displayName value=literal:Daily High Threshold/ -- binding name=disabled value=!currentChannelSetup.dailyThreshold.dailyThresholdEnabled/ /component when value is numeric 0 then the textfield also shows a blank. I don't understand this! Anybody got any ideas? -- Thanks A Jabbar Azam -- Thanks A Jabbar Azam - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Ryan Holmes, CISSP [EMAIL PROTECTED] ph. (213) 626-0026 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Thanks A Jabbar Azam - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Textfield validation problem
Sure, sounds like you want a numeric-only string. Tapestry has a Pattern validator, but I don't know if you can specify the pattern inside your 'validators:' value. I always set up pattern validators as beans and then reference them in the 'validators:' value, like so: bean name=numericValidator class=org.apache.tapestry.form.validator.Pattern lifecycle=page set name=pattern'^[0-9]+$'/set set name=message value=message:invalid-numeric-input / /bean component id=numericStringField type=TextField binding name=value value=myNumericString / binding name=displayName value=message:my-numeric-string- label / binding name=validators value=validators:required, $numericValidator / /component I'm using the '$' syntax to reference a bean in the 'validators:' value. Note that I'm using localizable message keys, but you can of course use literal strings for your messages. Also note that I'm setting 'lifecycle=page' in the bean definition. This should give slightly better performance by causing the bean to be instantiated only once, rather than on each page render. One more thing -- since this TextField represents a String value, you don't need to specify a translator unless you want to change the default string translation behavior (you probably already knew that). -Ryan On Oct 14, 2006, at 1:39 PM, Jabbar wrote: Ryan, Hello again. Is it possible to use a regular expression with a textfield? I don't want to use it to read a number, but a string. Thanks On 14/10/06, Ryan Holmes [EMAIL PROTECTED] wrote: Change this: binding name=translator value=translator:number,pattern=#.#/ to this: binding name=translator value=translator:number,pattern=#.#,omitZero=false/ The 'omitZero' property in org.apache.tapestry.form.translator.NumberTranslator is true by default. Paul Ferraro (who I believe contributed much of the translation and validation system for Tap 4.0) argues that omitZero should be false by default in this JIRA issue: http://issues.apache.org/jira/browse/TAPESTRY-633 So vote for it if you agree. -Ryan On Oct 14, 2006, at 11:44 AM, Jabbar wrote: Oops. The textfield component definition is component id=dailyHighThreshold type=TextField binding name=value value=currentChannelSetup.dailyThreshold.highThresholdDouble/ binding name=translator value=translator:number,pattern=#.#/ binding name=validators value=validators:required[You must enter {0}!], min=0/ binding name=displayName value=literal:Daily High Threshold/ binding name=disabled value=!currentChannelSetup.dailyThreshold.dailyThresholdEnabled/ /component On 14/10/06, Jabbar [EMAIL PROTECTED] wrote: Hello again, I have another problem. It concerns the textfield the definition is component id=dailyHighThreshold type=TextField binding name=value value=currentChannelSetup.dailyThreshold.highThresholdDouble/ !-- binding name=translator value=translator:number,pattern=#.#/ binding name=validators value=validators:required[You must enter {0}!], min=0/ binding name=displayName value=literal:Daily High Threshold/ -- binding name=disabled value=! currentChannelSetup.dailyThreshold.dailyThresholdEnabled/ /component when value is numeric 0 then the textfield also shows a blank. I don't understand this! Anybody got any ideas? -- Thanks A Jabbar Azam -- Thanks A Jabbar Azam - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Ryan Holmes, CISSP [EMAIL PROTECTED] ph. (213) 626-0026 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Thanks A Jabbar Azam - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]