You will want to use the following translator binding: translator="translator:number"
Paul Howard Lewis Ship wrote: > At the root of this is that the value comes up as a string, and if you > don't tell Tapestry otherwise, it stays a string ... but needs to be a > Number for max and min validators. > > The translator parameter controls this. You want to use > "translator:int" (I believe, check the docs). This will convert int > property on the server side to a string, and vice-versa. > > On 2/17/06, Jesse Kuhnert <[EMAIL PROTECTED]> wrote: > >> I meant more like the sample given in the translator parameter here ( >> http://jakarta.apache.org/tapestry/tapestry/ComponentReference/DatePicker.html >> ). >> >> >> >> On 2/17/06, Brian Long <[EMAIL PROTECTED]> wrote: >> >>> Jesse, >>> >>> do you mean like this? >>> >>> <input jwcid="[EMAIL PROTECTED]" value="translator:ognl:amount" >>> validators="validators:min=15,max=5000" size="10" /> >>> >>> Regards, Brian. >>> >>> On 2/17/06, Jesse Kuhnert <[EMAIL PROTECTED]> wrote: >>> >>>> Oh, try adding the translator: binding as well :) >>>> >>>> On 2/17/06, Brian Long <[EMAIL PROTECTED]> wrote: >>>> >>>>> Jesse, >>>>> >>>>> thanks for the quick reply, but I have bound the value to >>>>> "ognl:amount", which is a BigDecimal (a subclass of Number) used in my >>>>> java class? Is this a step to far for the Compiler/Tapestry framework, >>>>> because if what you say is true, this should have worked. >>>>> >>>>> Brian. >>>>> >>>>> On 2/17/06, Jesse Kuhnert <[EMAIL PROTECTED]> wrote: >>>>> >>>>>> You need to have you value binding for TextField be either a Numeric >>>>>> >>>>> object >>>>> >>>>>> type or native numeric value. That's just the way it is for >>>>>> >>> now...Won't >>> >>>>> be >>>>> >>>>>> in tap4.1... >>>>>> >>>>>> >>>>>> On 2/17/06, Brian Long <[EMAIL PROTECTED]> wrote: >>>>>> >>>>>>> Hi guys, >>>>>>> >>>>>>> I've spend this afternoon trying to get the minimum and maximum >>>>>>> >>>>> validators >>>>> >>>>>>> for Tapestry 4.0 to work without success. >>>>>>> >>>>>>> I have a TextField component with an associated FieldLabel >>>>>>> >>> component >>> >>>>> onto >>>>> >>>>>>> which I attach the Min and Max validators : >>>>>>> >>>>>>> <td> >>>>>>> <label jwcid="@FieldLabel" field="component:dummyTextField" >>>>>>> >>>>> displayName= >>>>> >>>>>>> "DummyTextField">DummyTextField</label> >>>>>>> </td> >>>>>>> <td> >>>>>>> <input jwcid="[EMAIL PROTECTED]" value="ognl:amount" >>>>>>> validators="validators:min=15,max=5000" >>>>>>> size="10" /> >>>>>>> </td> >>>>>>> >>>>>>> Pretty straightforward, or so you'd think! The problem is that I >>>>>>> >>> get a >>> >>>>>>> Class >>>>>>> Cast Exception when I run the application >>>>>>> >>>>>>> >>>>>>>>> java.lang.ClassCastException >>>>>>>>> java.lang.String >>>>>>>>> >>>>>>> in Tapestry and I enter data into this textfield and submit the >>>>>>> >>> form. >>> >>>>> The >>>>> >>>>>>> problem is that the validate method in Min Class ( >>>>>>> org.apache.tapestry.form.validator.Min.validate(Min.java:53)), as >>>>>>> >>> you >>> >>>>> can >>>>> >>>>>>> see it's trying to cast the contents of the received >>>>>>> Object to an Number, the problem it that this Object Contains a >>>>>>> >>>>> String, >>>>> >>>>>>> well, we are using a TextField component after all? >>>>>>> >>>>>>> public void validate(IFormComponent field, ValidationMessages >>>>>>> >>>>> messages, >>>>> >>>>>>> Object object) >>>>>>> throws ValidatorException >>>>>>> { >>>>>>> Number value = (Number) object; >>>>>>> >>>>>>> if (_min > value.doubleValue()) >>>>>>> throw new ValidatorException(buildMessage(messages, >>>>>>> >>>>> field), >>>>> >>>>>>> ValidationConstraint.TOO_SMALL); >>>>>>> } >>>>>>> >>>>>>> Now I know that you can't cast from a String to a >>>>>>> Number,Integer,BigDecimal >>>>>>> etc, but it's an Object we're casting from. I >>>>>>> know that it contains a string, but its a numeric string i.e"123", is >>>>>>> >>>>> it >>>>> >>>>>>> that the Min class is at fault here or is it something I'm >>>>>>> doing wrong? >>>>>>> >>>>>>> If Jesse Kuhnert is reading this and has five minutes to deliver >>>>>>> >>> the >>> >>>>>>> answer >>>>>>> to my question it would be much appreciated. >>>>>>> >>>>>>> Brian Long. >>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>> --------------------------------------------------------------------- >>>>> 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] >>> >>> >>> >> > > > -- > Howard M. Lewis Ship > Independent J2EE / Open-Source Java Consultant > Creator, Jakarta Tapestry > Creator, Jakarta HiveMind > > Professional Tapestry training, mentoring, support > and project work. http://howardlewisship.com > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
smime.p7s
Description: S/MIME Cryptographic Signature
