Hello, So:
How do I define save callBack? I tried:
and defined save in both instance or class side of MyObject, but that didn't work. Regards, Vitor. |
Hi Vitor,
It has been a while that I really used Magritte, but basically the problem that you encounter is that the save is not called on MyObject, but on the component that is created from MyObject (in the method asComponent). The save method calls the save on the component, and in Magritte that is implemented, so without doing much it should perform the following code: MAContainerComponent >> save self validate ifFalse: [ ^ self ]. self commit; answer: self model The validate calls the validation rules on the magritteDescription, the commit stores the changes the user made in the object, and answer allows the container to do further actions for the same event (as the button is actually created in the decoration, and not in the container itself). So when you want to intercept the save method, you could use a block instead of a simple symbol: MyObject new asComponent addValidatedForm : { [ :container | | myObject | “ do something you want to do before the save takes place “ container save. myObject := container model. “ when it reaches here, the save was successful and you can send a message to myObject, i.e. “ myObject save ] -> 'save'. #cancel -> 'cancel'}. Another approach is to change the component that is created by overriding the componentClass of MyObject, and implementing the save in the new subclass you created. Regards, Diego
|
OMG Thank You! I figure the first part, but I went crazy here debugging, and I probably would never ever figure the second part, a list with a block... Is there documentation for that somewhere? In https://github.com/magritte-metamodel/magritte most of docs links are broken.... :´( On Sun, Dec 30, 2018 at 4:51 PM Diego Lont <[hidden email]> wrote:
|
Free forum by Nabble | Edit this page |