You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jabbar <aj...@gmail.com> on 2006/10/14 20:41:15 UTC
Textfield validation problem
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
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Textfield validation problem
Posted by Ryan Holmes <ry...@hyperstep.com>.
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 <ry...@hyperstep.com> 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 <aj...@gmail.com> 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: users-unsubscribe@tapestry.apache.org
>> > For additional commands, e-mail: users-help@tapestry.apache.org
>> >
>>
>> Ryan Holmes, CISSP
>>
>> ryan@hyperstep.com
>> ph. (213) 626-0026
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
>
> --
> Thanks
>
> A Jabbar Azam
>
> ---------------------------------------------------------------------
> 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: Textfield validation problem
Posted by Jabbar <aj...@gmail.com>.
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 <ry...@hyperstep.com> 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 <aj...@gmail.com> 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: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
>
> Ryan Holmes, CISSP
>
> ryan@hyperstep.com
> ph. (213) 626-0026
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
Thanks
A Jabbar Azam
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Textfield validation problem
Posted by Ryan Holmes <ry...@hyperstep.com>.
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 <aj...@gmail.com> 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: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
Ryan Holmes, CISSP
ryan@hyperstep.com
ph. (213) 626-0026
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Textfield validation problem
Posted by Jabbar <aj...@gmail.com>.
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 <aj...@gmail.com> 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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org