You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Kamal Bhatt <kb...@tt.com.au> on 2006/02/26 23:15:13 UTC

cforms - validating integers

Hi
I have a cform with the following field:

    <fd:field id="min_duration" required="false">
        <fd:label>Min Duration</fd:label>
        <fd:datatype base="integer"/>
        <fd:validation>
          <fd:regexp pattern="[0-9]*"/>
          <fd:range min="1" max="99">
            <fd:failmessage>Max duration must an integer greater than 1 
and less than 99</fd:failmessage>
          </fd:range>
         </fd:validation>
    </fd:field>

When I enter a non-integer character (eg 'a'), the cform fails on save. 
All other validation works, but obviously, validation does not work 
until the field is bound to the variable. My question is how to get the 
field to validate without using javascript (at the form template level) 
to do so (for the sake of consistency).

Cheers.

Kamal.

-- 
Kamal Bhatt

Tourism Technology Pty Ltd


T:  +61 (02) 9956 7300
F:  +61 (02) 9956 7411


Level 10, 1 Pacific Highway, North Sydney, NSW 2060

 
http://www.tt.com.au


--
Disclaimer: This email is confidential and may contain privileged information for the sole use of the person or business to which it is addressed. If you are not the intended recipient, please notify the sender by return e-mail or phone as you must not view, disseminate, distribute or copy this email without our consent. We do not accept any liability in connection with any computer virus, data corruption, incompleteness, or unauthorised amendment of this email. It is the sole responsibility of the receiver to scan for viruses before opening.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: cforms - validating integers

Posted by Simone Gianni <s....@thebug.it>.
Hi Kamal,
default forms messages are internationalized, so you can change the 
default message with something else acting on the i18n bundle files.

Simone

Kamal Bhatt wrote:

>
> Simone Gianni wrote:
>
>> Hi Kamal,
>> remove the fd:regexp validation from non-string fields. You don't 
>> need it.
>>
> Thanks. However, the fail message is appalling, how do I change the 
> error message to be something nicer?
>
>> Simone
>>
>> Kamal Bhatt wrote:
>>
>>>
>>> What do I do with the class cast exception?
>>> Simone Gianni wrote:
>>>
>>>> Hi Kamal,
>>>> AFAIK you cannot (and don't need) to apply a fd:regexp to an 
>>>> integer, it should give you class cast exception. Validation is 
>>>> applied after conversion takes place, and the convertor for an 
>>>> integer will not allow presence of letters by itself.
>>>>
>>>> Simone
>>>>
>>>> Kamal Bhatt wrote:
>>>>
>>>>>
>>>>> OK, this is a mistake on my part. This is a problem not with 
>>>>> validation as I thought but with form in general (ie it is not 
>>>>> saving even when the fields are valid). I will probably repost 
>>>>> when I have  looked into this further.
>>>>>
>>>>> Cheers.
>>>>> Kamal Bhatt wrote:
>>>>>
>>>>>>
>>>>>> Hi
>>>>>> I have a cform with the following field:
>>>>>>
>>>>>>    <fd:field id="min_duration" required="false">
>>>>>>        <fd:label>Min Duration</fd:label>
>>>>>>        <fd:datatype base="integer"/>
>>>>>>        <fd:validation>
>>>>>>          <fd:regexp pattern="[0-9]*"/>
>>>>>>          <fd:range min="1" max="99">
>>>>>>            <fd:failmessage>Max duration must an integer greater 
>>>>>> than 1 and less than 99</fd:failmessage>
>>>>>>          </fd:range>
>>>>>>         </fd:validation>
>>>>>>    </fd:field>
>>>>>>
>>>>>> When I enter a non-integer character (eg 'a'), the cform fails on 
>>>>>> save. All other validation works, but obviously, validation does 
>>>>>> not work until the field is bound to the variable. My question is 
>>>>>> how to get the field to validate without using javascript (at the 
>>>>>> form template level) to do so (for the sake of consistency).
>>>>>>
>>>>>> Cheers.
>>>>>>
>>>>>> Kamal.
>>>>>>
>>>>>
>>>>>
>>>
>>>
>
>
-- 
Simone Gianni

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: cforms - validating integers

Posted by Kamal Bhatt <kb...@tt.com.au>.
Simone Gianni wrote:

> Hi Kamal,
> remove the fd:regexp validation from non-string fields. You don't need 
> it.
>
Thanks. However, the fail message is appalling, how do I change the 
error message to be something nicer?

> Simone
>
> Kamal Bhatt wrote:
>
>>
>> What do I do with the class cast exception?
>> Simone Gianni wrote:
>>
>>> Hi Kamal,
>>> AFAIK you cannot (and don't need) to apply a fd:regexp to an 
>>> integer, it should give you class cast exception. Validation is 
>>> applied after conversion takes place, and the convertor for an 
>>> integer will not allow presence of letters by itself.
>>>
>>> Simone
>>>
>>> Kamal Bhatt wrote:
>>>
>>>>
>>>> OK, this is a mistake on my part. This is a problem not with 
>>>> validation as I thought but with form in general (ie it is not 
>>>> saving even when the fields are valid). I will probably repost when 
>>>> I have  looked into this further.
>>>>
>>>> Cheers.
>>>> Kamal Bhatt wrote:
>>>>
>>>>>
>>>>> Hi
>>>>> I have a cform with the following field:
>>>>>
>>>>>    <fd:field id="min_duration" required="false">
>>>>>        <fd:label>Min Duration</fd:label>
>>>>>        <fd:datatype base="integer"/>
>>>>>        <fd:validation>
>>>>>          <fd:regexp pattern="[0-9]*"/>
>>>>>          <fd:range min="1" max="99">
>>>>>            <fd:failmessage>Max duration must an integer greater 
>>>>> than 1 and less than 99</fd:failmessage>
>>>>>          </fd:range>
>>>>>         </fd:validation>
>>>>>    </fd:field>
>>>>>
>>>>> When I enter a non-integer character (eg 'a'), the cform fails on 
>>>>> save. All other validation works, but obviously, validation does 
>>>>> not work until the field is bound to the variable. My question is 
>>>>> how to get the field to validate without using javascript (at the 
>>>>> form template level) to do so (for the sake of consistency).
>>>>>
>>>>> Cheers.
>>>>>
>>>>> Kamal.
>>>>>
>>>>
>>>>
>>
>>


-- 
Kamal Bhatt

Tourism Technology Pty Ltd


T:  +61 (02) 9956 7300
F:  +61 (02) 9956 7411


Level 10, 1 Pacific Highway, North Sydney, NSW 2060

 
http://www.tt.com.au


--
Disclaimer: This email is confidential and may contain privileged information for the sole use of the person or business to which it is addressed. If you are not the intended recipient, please notify the sender by return e-mail or phone as you must not view, disseminate, distribute or copy this email without our consent. We do not accept any liability in connection with any computer virus, data corruption, incompleteness, or unauthorised amendment of this email. It is the sole responsibility of the receiver to scan for viruses before opening.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: cforms - validating integers

Posted by Simone Gianni <s....@thebug.it>.
Hi Kamal,
remove the fd:regexp validation from non-string fields. You don't need it.

Simone

Kamal Bhatt wrote:

>
> What do I do with the class cast exception?
> Simone Gianni wrote:
>
>> Hi Kamal,
>> AFAIK you cannot (and don't need) to apply a fd:regexp to an integer, 
>> it should give you class cast exception. Validation is applied after 
>> conversion takes place, and the convertor for an integer will not 
>> allow presence of letters by itself.
>>
>> Simone
>>
>> Kamal Bhatt wrote:
>>
>>>
>>> OK, this is a mistake on my part. This is a problem not with 
>>> validation as I thought but with form in general (ie it is not 
>>> saving even when the fields are valid). I will probably repost when 
>>> I have  looked into this further.
>>>
>>> Cheers.
>>> Kamal Bhatt wrote:
>>>
>>>>
>>>> Hi
>>>> I have a cform with the following field:
>>>>
>>>>    <fd:field id="min_duration" required="false">
>>>>        <fd:label>Min Duration</fd:label>
>>>>        <fd:datatype base="integer"/>
>>>>        <fd:validation>
>>>>          <fd:regexp pattern="[0-9]*"/>
>>>>          <fd:range min="1" max="99">
>>>>            <fd:failmessage>Max duration must an integer greater 
>>>> than 1 and less than 99</fd:failmessage>
>>>>          </fd:range>
>>>>         </fd:validation>
>>>>    </fd:field>
>>>>
>>>> When I enter a non-integer character (eg 'a'), the cform fails on 
>>>> save. All other validation works, but obviously, validation does 
>>>> not work until the field is bound to the variable. My question is 
>>>> how to get the field to validate without using javascript (at the 
>>>> form template level) to do so (for the sake of consistency).
>>>>
>>>> Cheers.
>>>>
>>>> Kamal.
>>>>
>>>
>>>
>
>
-- 
Simone Gianni

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: cforms - validating integers

Posted by Kamal Bhatt <kb...@tt.com.au>.
What do I do with the class cast exception?
Simone Gianni wrote:

> Hi Kamal,
> AFAIK you cannot (and don't need) to apply a fd:regexp to an integer, 
> it should give you class cast exception. Validation is applied after 
> conversion takes place, and the convertor for an integer will not 
> allow presence of letters by itself.
>
> Simone
>
> Kamal Bhatt wrote:
>
>>
>> OK, this is a mistake on my part. This is a problem not with 
>> validation as I thought but with form in general (ie it is not saving 
>> even when the fields are valid). I will probably repost when I have  
>> looked into this further.
>>
>> Cheers.
>> Kamal Bhatt wrote:
>>
>>>
>>> Hi
>>> I have a cform with the following field:
>>>
>>>    <fd:field id="min_duration" required="false">
>>>        <fd:label>Min Duration</fd:label>
>>>        <fd:datatype base="integer"/>
>>>        <fd:validation>
>>>          <fd:regexp pattern="[0-9]*"/>
>>>          <fd:range min="1" max="99">
>>>            <fd:failmessage>Max duration must an integer greater than 
>>> 1 and less than 99</fd:failmessage>
>>>          </fd:range>
>>>         </fd:validation>
>>>    </fd:field>
>>>
>>> When I enter a non-integer character (eg 'a'), the cform fails on 
>>> save. All other validation works, but obviously, validation does not 
>>> work until the field is bound to the variable. My question is how to 
>>> get the field to validate without using javascript (at the form 
>>> template level) to do so (for the sake of consistency).
>>>
>>> Cheers.
>>>
>>> Kamal.
>>>
>>
>>


-- 
Kamal Bhatt

Tourism Technology Pty Ltd


T:  +61 (02) 9956 7300
F:  +61 (02) 9956 7411


Level 10, 1 Pacific Highway, North Sydney, NSW 2060

 
http://www.tt.com.au


--
Disclaimer: This email is confidential and may contain privileged information for the sole use of the person or business to which it is addressed. If you are not the intended recipient, please notify the sender by return e-mail or phone as you must not view, disseminate, distribute or copy this email without our consent. We do not accept any liability in connection with any computer virus, data corruption, incompleteness, or unauthorised amendment of this email. It is the sole responsibility of the receiver to scan for viruses before opening.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: cforms - validating integers

Posted by Simone Gianni <s....@thebug.it>.
Hi Kamal,
AFAIK you cannot (and don't need) to apply a fd:regexp to an integer, it 
should give you class cast exception. Validation is applied after 
conversion takes place, and the convertor for an integer will not allow 
presence of letters by itself.

Simone

Kamal Bhatt wrote:

>
> OK, this is a mistake on my part. This is a problem not with 
> validation as I thought but with form in general (ie it is not saving 
> even when the fields are valid). I will probably repost when I have  
> looked into this further.
>
> Cheers.
> Kamal Bhatt wrote:
>
>>
>> Hi
>> I have a cform with the following field:
>>
>>    <fd:field id="min_duration" required="false">
>>        <fd:label>Min Duration</fd:label>
>>        <fd:datatype base="integer"/>
>>        <fd:validation>
>>          <fd:regexp pattern="[0-9]*"/>
>>          <fd:range min="1" max="99">
>>            <fd:failmessage>Max duration must an integer greater than 
>> 1 and less than 99</fd:failmessage>
>>          </fd:range>
>>         </fd:validation>
>>    </fd:field>
>>
>> When I enter a non-integer character (eg 'a'), the cform fails on 
>> save. All other validation works, but obviously, validation does not 
>> work until the field is bound to the variable. My question is how to 
>> get the field to validate without using javascript (at the form 
>> template level) to do so (for the sake of consistency).
>>
>> Cheers.
>>
>> Kamal.
>>
>
>
-- 
Simone Gianni

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: cforms - validating integers

Posted by Kamal Bhatt <kb...@tt.com.au>.
OK, this is a mistake on my part. This is a problem not with validation 
as I thought but with form in general (ie it is not saving even when the 
fields are valid). I will probably repost when I have  looked into this 
further.

Cheers. 

Kamal Bhatt wrote:

>
> Hi
> I have a cform with the following field:
>
>    <fd:field id="min_duration" required="false">
>        <fd:label>Min Duration</fd:label>
>        <fd:datatype base="integer"/>
>        <fd:validation>
>          <fd:regexp pattern="[0-9]*"/>
>          <fd:range min="1" max="99">
>            <fd:failmessage>Max duration must an integer greater than 1 
> and less than 99</fd:failmessage>
>          </fd:range>
>         </fd:validation>
>    </fd:field>
>
> When I enter a non-integer character (eg 'a'), the cform fails on 
> save. All other validation works, but obviously, validation does not 
> work until the field is bound to the variable. My question is how to 
> get the field to validate without using javascript (at the form 
> template level) to do so (for the sake of consistency).
>
> Cheers.
>
> Kamal.
>


-- 
Kamal Bhatt

Tourism Technology Pty Ltd


T:  +61 (02) 9956 7300
F:  +61 (02) 9956 7411


Level 10, 1 Pacific Highway, North Sydney, NSW 2060

 
http://www.tt.com.au


--
Disclaimer: This email is confidential and may contain privileged information for the sole use of the person or business to which it is addressed. If you are not the intended recipient, please notify the sender by return e-mail or phone as you must not view, disseminate, distribute or copy this email without our consent. We do not accept any liability in connection with any computer virus, data corruption, incompleteness, or unauthorised amendment of this email. It is the sole responsibility of the receiver to scan for viruses before opening.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org