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.... :´(
<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Livre de vírus. www.avg.com <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>. <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> On Sun, Dec 30, 2018 at 4:51 PM Diego Lont <[email protected]> wrote: > 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 > > On 29 Dec 2018, at 17:14, Vitor Medina Cruz <[email protected]> wrote: > > Hello, > > So: > >> >> MyObject new asComponent addValidatedForm >> > > How do I define save callBack? > > I tried: > > MyObject new asComponent addValidatedForm : {#save -> 'save'. #cancel -> >> 'cancel'}. >> > > and defined save in both instance or class side of MyObject, but that > didn't work. > > Regards, > Vitor. > > > <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> > Livre > de vírus. www.avg.com > <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>. > > > >
