Validation in component

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Validation in component

keith1y
Hello,

I am attempting to write a component that displays two fields for
text/password entry, in order to check that both user entries are the same.

However the method #validate is never called on the component. Is this
to be expected?

My field is part of a record that is edited using an InternalEditor, I
am wondering whether the following method should be...

MAValidatorVisitor visitReferenceDescription: anObject

    self visitElementDescription: anObject reference

cheers

Keith


_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Validation in component

Lukas Renggli-2
> However the method #validate is never called on the component. Is this
> to be expected?

Yes, that's how it is implemented. I agree that this is a bit strange.

> My field is part of a record that is edited using an InternalEditor, I
> am wondering whether the following method should be...
>
> MAValidatorVisitor visitReferenceDescription: anObject
>
>    self visitElementDescription: anObject reference

You might want to add such an extension method, if it solves your  
problem. In general this should rather be a property of the meta model  
to know if a reference should be followed when validating or not.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch


_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Validation in component

keith1y
Lukas Renggli wrote:
>> However the method #validate is never called on the component. Is this
>> to be expected?
>>    
>
> Yes, that's how it is implemented. I agree that this is a bit strange.
>
>  
And I thought that this would be easy!

Keith


_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Validation in component

keith1y
In reply to this post by Lukas Renggli-2
Lukas Renggli wrote:
>> However the method #validate is never called on the component. Is this
>> to be expected?
>>    
>
> Yes, that's how it is implemented. I agree that this is a bit strange.
>  
So how come MADateSelectorComponent implements #validate, if no one
calls it?

anyone?

Keith


_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Validation in component

keith1y
Keith Hodges wrote:

> Lukas Renggli wrote:
>  
>>> However the method #validate is never called on the component. Is this
>>> to be expected?
>>>    
>>>      
>> Yes, that's how it is implemented. I agree that this is a bit strange.
>>  
>>    
> So how come MADateSelectorComponent implements #validate, if no one
> calls it?
>
> anyone?
>
> Keith
>  
I uploaded a modification to magritte-seaside in which #save/#apply
calls #doValidate on the MAContainerComponent which collects the errors.
#doValidate validates the memento as before but in addition it calls
#validate on all contained non-readonly components.

This means that #validate is now called on MADateSelector etc. (I could
not see where this was being called before, and your comment above
indicated that it wasnt. MAInternalEditorComponent propagates #validate
to its own container component and its children in turn.

This allows my "enter the text/password twice" component to raise an
exception if the two entry fields do not match.

I also added #valueOriginal to MAElementComponent which allows
validation to compare with the original value. i.e. if the password is
unchanged, dont worry about the second entry field.

Would you have any interest in this dual entry component as an addition
to the base Magritte-Seaside ?

best regards

Keith



_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Validation in component

Lukas Renggli-2
In reply to this post by keith1y
> So how come MADateSelectorComponent implements #validate, if no one  
> calls it?

Obviously a bug. In the early days of Magritte the components did the  
validation themselves, it was later moved to the meta model.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch


_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Validation in component

Lukas Renggli-2
In reply to this post by keith1y
>> I uploaded a modification to magritte-seaside in which #save/#apply
> calls #doValidate on the MAContainerComponent which collects the  
> errors.
> #doValidate validates the memento as before but in addition it calls
> #validate on all contained non-readonly components.

I think #doValidate and #validate should be swapped, otherwise you  
break existing clients.

> Would you have any interest in this dual entry component as an  
> addition
> to the base Magritte-Seaside ?

Yes, please. That sounds interesting.

Cheers,
Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch


_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Validation in component

keith1y
Lukas Renggli wrote:

>>> I uploaded a modification to magritte-seaside in which #save/#apply
>>>      
>> calls #doValidate on the MAContainerComponent which collects the  
>> errors.
>> #doValidate validates the memento as before but in addition it calls
>> #validate on all contained non-readonly components.
>>    
>
> I think #doValidate and #validate should be swapped, otherwise you  
> break existing clients.
>
>  
I dont think so... since memento already implements #validate to perform
the actual validation. Therefore components should also implement
#validate for consistency.

#doValidate only need to be implemented by the MAContainerComponent and
is only called once.


Keith


_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Validation in component

Lukas Renggli-2
>> I think #doValidate and #validate should be swapped, otherwise you
>> break existing clients.
>
> I dont think so... since memento already implements #validate to  
> perform
> the actual validation. Therefore components should also implement
> #validate for consistency.

Your changes break Pier and a few commercial applications I am  
currently working on.

> #doValidate only need to be implemented by the MAContainerComponent  
> and
> is only called once.

I refactored the changes and added a component that shows two password  
input fields for confirmation in

        Name: Magritte-Seaside-lr.278
        Author: lr
        Time: 21 September 2008, 10:45:19 am
        UUID: 93886626-e728-41af-9e10-52f0d0d569fe
        Ancestors: Magritte-Seaside-lr.277

        - added a validated password component
        - refactored component validation so that it does not break backwards  
compatiblity

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch


_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Validation in component

keith1y
Lukas Renggli wrote:

>>> I think #doValidate and #validate should be swapped, otherwise you
>>> break existing clients.
>>>      
>> I dont think so... since memento already implements #validate to  
>> perform
>> the actual validation. Therefore components should also implement
>> #validate for consistency.
>>    
>
> Your changes break Pier and a few commercial applications I am  
> currently working on.
>
>  
How can they break pier, since I am using it in pier

Keith

_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Validation in component

Lukas Renggli-2
I have code that calls #validate on the component (you are right, this  
is not Pier) and expects to get a boolean returned. I think my last  
cleanup (move all the actions to MAContainerComponent) of the  
MADescriptionComponent hierarchy makes things more clear without  
breaking existing dependencies.

Lukas

On Sep 21, 2008, at 18:48 , Keith Hodges wrote:

> Lukas Renggli wrote:
>>>> I think #doValidate and #validate should be swapped, otherwise you
>>>> break existing clients.
>>>>
>>> I dont think so... since memento already implements #validate to
>>> perform
>>> the actual validation. Therefore components should also implement
>>> #validate for consistency.
>>>
>>
>> Your changes break Pier and a few commercial applications I am
>> currently working on.
>>
>>
> How can they break pier, since I am using it in pier
>
> Keith
>
> _______________________________________________
> SmallWiki, Magritte, Pier and Related Tools ...
> https://www.iam.unibe.ch/mailman/listinfo/smallwiki

--
Lukas Renggli
http://www.lukas-renggli.ch


_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki