Hello, Scott Eade,

        thanks for your help,but there is still a problem :
        when i input some other chars like "abc" in the field and submit
there is an error accurs,turbine throws an exception "NumberFormatException",
and i look for the source code ,and find some code like this in the IntegerField.java

    protected void doSetValue(ParameterParser pp)
    {
        if ( isMultiValued  ) 
        {
            String[] ss = pp.getStrings(getKey());
            int[] ival = new int[ss.length];
            for (int i=0; i<ss.length; i++) 
            {
                    ival[i] = Integer.parseInt(ss[i]);
            }
            setTestValue(ival);
        }
        else 
        {
                setTestValue(new Integer(pp.getString(getKey())));
        }
    }

when use the "Integer.parseInt",it doesn't deal with the exception,
and i find in the IntakeTool.java

        public Group mapTo(Retrievable obj)
            throws Exception
        {
            Group g = null;

            try 
            {
                String inputKey = TurbineIntake.getGroupKey(groupName) 
                    + obj.getQueryKey();
                if ( groups.containsKey(inputKey)) 
                {
                    g = (Group)groups.get(inputKey);
                }
                else 
                {
                    g = TurbineIntake.getGroup(groupName); 
                    groups.put(inputKey, g);
                }
                return g.init(obj);
            }
            catch(Exception e)
            {
                Log.error(e);
            }

            return null;
        }

this function deal with the exception may be thrown mentioned before(Integer.parseInt)
actually,if i input some none-number chars in the "int" field ,intake.isAllValid will 
not
return an false or true,just an error accurs.
    so ,i edit the sourcecode in IntegerField.java and try-catch when Integer.parseInt,
then ,it works,but another problem ,when i input some "abc" in the int field ,
$mygroup.MyField.Message shows "Entry was not a valid integer",this message is defined
in IntegerValidator.java,i think this is not so good :)
        and anyone met these problem yet?

ps:i use turbine 2.1,and intake is in it.

======= At 2002-05-15, 19:41:00 you wrote: =======

><required-message> is for when you will be dynamically setting whether or
>not the field is required.
>
>I think what you want is:
><rule name="required" value="true">Please enter a value.</rule>
>
>I'm using the intake from tdk2.1 with a couple of very minor patches.  When
>I enter a large number into an int field I get some kind of error (doesn't
>spring to mind) even when I have specified a maxValue rule.  Something to
>watch out for.
>
>Scott
>
>> From: "argan" <[EMAIL PROTECTED]>
>> Organization: ali
>> Reply-To: "Turbine Users List" <[EMAIL PROTECTED]>
>> Date: Wed, 15 May 2002 17:13:46 +0800
>> To: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
>> Subject: how to validate an "int" field with intake?
>> 
>> Hello,
>>  how can i validate an "int" field with intake?
>> in my intake.xml,there is a field
>> <group ....>
>>   <field name="LeadsCount" key="leadscount" type="int"
>> mapToProperty="LeadsCount">
>> <rule name="mask" value="^$|[0-9]+">Please input a valid count</rule>
>> <rule name="minValue" value="0">Value must greater than 0</rule>
>> <rule name="maxValue" value="65535">Value can not greater than 65535</rule>
>>       <required-message>This module requires a valid count.</required-message>
>>   </field>
>> </group>
>> 
>> but it doesn't work,why?
>> 
>> 
>> 
>> 
>> 
>> 
>> --
>> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
>> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>> 
>
>
>--
>To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

= = = = = = = = = = = = = = = = = = = =
                        

Best regards.                            
kerry
[EMAIL PROTECTED]
2002-05-16




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to