cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Quinn <jer...@media.demon.co.uk>
Subject Re: validating fd:booleanfield
Date Thu, 01 Jul 2004 10:09:13 GMT

On 30 Jun 2004, at 17:56, Bruno Dumon wrote:

Thanks for your response Bruno.

> On Wed, 2004-06-30 at 13:01, Jeremy Quinn wrote:
>> Hi All
>>
>> I need to validate (within the CForms framework) that a set of
>> checkboxes have all been checked.
>>
>> I have tried adding <fd:validation/> but it does not appear to have an
>> effect :
>
> Checked the source: it's indeed not supported. Probably for no
> particular reason.
>
> Possible options are:
>
> * adding support for it.

sounds good

> Should be no more then adding the following
> line to the class BooleanFieldDefinitionBuilder:
> setValidators(widgetElement, definition);
> I don't have time to test that, but since you already have an example
> worked out you could give it a try.

OK, I added setValidators(widgetElement, definition); at line 34, in 
the buildWidgetDefinition method.

I then test with the following booleanfield:

<fd:booleanfield id="mod-copyright">
   <fd:label>
     <i18n:text 
i18n:catalogue="local">moderate.mod-copyright.label</i18n:text>:
   </fd:label>
   <fd:hint>
     <i18n:text 
i18n:catalogue="local">moderate.mod-copyright.hint</i18n:text>
   </fd:hint>
   <fd:help>
     <i18n:text 
i18n:catalogue="local">moderate.mod-copyright.help</i18n:text>
   </fd:help>
   <fd:validation>
     <fd:assert test="mod-copyright = True()">
       <fd:failmessage>
         <i18n:text 
i18n:catalogue="local">moderate.mod-copyright.fail</i18n:text>
       </fd:failmessage>
     </fd:assert>
   </fd:validation>
</fd:booleanfield>

When I submit this form with the checkbox unchecked, I get no 
validation error displayed.

Comparing Field to BooleanField, it looks like BooleanField needs to 
implement ValidationErrorAware, so I will try that next.

>
> * on any widget you can add validators at runtime using the 
> addValidator
> method.

I will try that if the above fails to work, assuming no one is against 
me committing the above changes to CVS.

> Given that you need to check a set of checkboxes, it might be
> easier to add a validator to the parent widget of those checkboxes,
> rather then adding a validator to each seperate checkbox.

I am not sure I like the idea of embedding knowledge of my form in a 
Java Class.


many thanks

regards Jeremy

>>
>> <fd:booleanfield id="mod-copyright">
>>    <fd:label>
>>      <i18n:text
>> i18n:catalogue="local">moderate.mod-copyright.label</i18n:text>:
>>    </fd:label>
>>    <fd:hint>
>>      <i18n:text
>> i18n:catalogue="local">moderate.mod-copyright.hint</i18n:text>
>>    </fd:hint>
>>    <fd:help>
>>      <i18n:text
>> i18n:catalogue="local">moderate.mod-copyright.help</i18n:text>
>>    </fd:help>
>>
>>    <!-- this does not work -->
>>    <fd:validation>
>>      <fd:assert test="mod-copyright = true">
>>        <fd:failmessage>
>>          <i18n:text
>> i18n:catalogue="local">moderate.mod-copyright.error</i18n:text>
>>        </fd:failmessage>
>>      </fd:assert>
>>    </fd:validation>
>>
>> </fd:booleanfield>
>>
>> Is there a way of handling this?
>>
>> thanks for any suggestions.
>>
>> regards Jeremy
>>
>
> -- 
> Bruno Dumon                             http://outerthought.org/
> Outerthought - Open Source, Java & XML Competence Support Center
> bruno@outerthought.org                          bruno@apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
--------------------------------------------------------

                   If email from this address is not signed
                                 IT IS NOT FROM ME

                         Always check the label, folks !!!!!
--------------------------------------------------------


Mime
View raw message