You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Дрон <dr...@yandex.ru> on 2008/02/26 13:39:31 UTC

ROP: validation and callbacks

Hi!

I've got yet another question about ROP. 
First, i can't figure out how to invoke some existing validation code manually.

Right now i don't have any 'Validating' interfaces implemented in my classes, but still there are some constraints provided by cayenne.xml (like maximum length of a text field).
I guess this validation is invoked during 'validateForX' methods in SERVER classes. Note that CLIENT classes don't event implement the 'Validating' interface, because they extend 'PersistentObject', not 'CayenneDataObject'.
i don't actually understand the ROP architecture, but it seems that server classes functions are somehow invoked during work with client classes. Also, if validation fails, i get exception with mention of server class.

It is a good idea to check objects before making 'commintChanges', so the question is, how can i manually invoke that already existing validation from client side? And will my own validation work if i implement 'Validating' by client class (how will it collide with that existing validation)?


The second problem is that lifecycle callbacks don't seem to work with ROP at all. I add listener to ObjectContext.getEntityResolver.getCallbackRegistry(), but it is never invoked. It this feature implemented?

Thanks,
Andrey

Re: Re[3]: ROP: validation and callbacks

Posted by Andrus Adamchik <an...@objectstyle.org>.
Agreed, totally makes sense. Could you please open a feature request  
in Jira:

http://issues.apache.org/cayenne/

Thanks,
Andrus

On Feb 27, 2008, at 7:27 PM, Razumovsky Andrey wrote:

> I've found the answer: it turns out that client 'ObjAttribute'  
> descendant, 'ClientObjAttribute' needed validation information. I  
> think it is a good idea to make those 'isMandatory' and  
> 'getMaxLength' methods members of 'ObjAttribute' so that the same  
> validation code would work on client and server (server's objattrs  
> will reference to DbAttribute). How do you think?)
>


Re[3]: ROP: validation and callbacks

Posted by Razumovsky Andrey <hm...@hotmail.ru>.
I've found the answer: it turns out that client 'ObjAttribute' descendant, 'ClientObjAttribute' needed validation information. I think it is a good idea to make those 'isMandatory' and 'getMaxLength' methods members of 'ObjAttribute' so that the same validation code would work on client and server (server's objattrs will reference to DbAttribute). How do you think?)

Re[2]: ROP: validation and callbacks

Posted by Razumovsky Andrey <hm...@hotmail.ru>.
AA> Answering one of the questions, this is correct - there is no  
AA> callbacks available on the client.
AA> Andrus

Understood.

About my first question.. I tried to invoke manually validation (forSave) from CayenneDataObject to my client PersistentObject (i.e. to copy-paste the code). Still this didn't work.
First, the ObjEntity.dbEntityName and ObjAttribute.dbAttributePath are nulls while working on client. This is not so bad since i can make some workaround by setting them to needed value.
But the problem is, that client's DataMap, which is accessed by ObjEntity.getDataMap() has no DbEntities loaded, i.e. dbEntityMap is empty, while objEntityMap is correctly fulfilled. So i cannot access constraints described for my DbEntities in DataMap.
Is there any way i can fetch DBEntity object from client?

Thanks,
Andrey

Re: ROP: validation and callbacks

Posted by Andrus Adamchik <an...@objectstyle.org>.
On Feb 26, 2008, at 2:39 PM, Дрон wrote:

>
> The second problem is that lifecycle callbacks don't seem to work  
> with ROP at all. I add listener to  
> ObjectContext.getEntityResolver.getCallbackRegistry(), but it is  
> never invoked. It this feature implemented?

Answering one of the questions, this is correct - there is no  
callbacks available on the client.

Andrus