Hi,

I would also be interested to know the right answer to this question. In 
magnolia 4.4 it was kind of obvious how you could extend the Dialog class and 
override the save(), preSave() and postSave() methods... in magnolia 5 with 
Vaadin it isn't obvious to me how it ought to be done.

One way it could be handled might be (based on a quick glance at the code):

- Create your own subclass of SaveDialogAction
- Override the constructor to provide a wrapper implementation of 
EditorCallback to the superclass constructor.
- Your wrapper implementation overrides the onSuccess method of EditorCallback 
to first call the original callback's onSuccess method, and then do your custom 
stuff
- Your wrapper for onCancel will probably just call the original callback's 
onCancel method.

So something like:

public class MySaveAction extends SaveDialogAction<SaveDialogActionDefinition> {

  public MySaveAction(SaveDialogActionDefinition definition, Item item, 
EditorValidator validator, EditorCallback callback){
    super(definition, item, validator, new EditorCallbackWrapper(callback));
  }

  public class EditorCallbackWrapper implements EditorCallback {
    EditorCallback originalCallback = null;
    public EditorCallbackWrapper(EditorCallback original) {
      originalCallback = original;
    }

   void onCancel() {  originalCallback.onCancel(); }

    void onSuccess(String actionName) {
        originalCallback.onSuccess(actionName);
       // TODO your custom stuff goes here...
    }

  }

} 

Regards from Vienna,

Richard

> -----Ursprüngliche Nachricht-----
> Von: [email protected] [mailto:user-list-owner@magnolia-
> cms.com] Im Auftrag von Kars Blom (via Magnolia Forums)
> Gesendet: Donnerstag, 09. Jänner 2014 14:37
> An: Magnolia User List
> Betreff: [magnolia-user] Executing extra code after SaveDialogAction
> 
> Hi,
> 
> I want to do some extra logic on a dialog action that first saves all 
> properties
> to the JCR (basically SaveDialogAction, then doing some extra stuff).
> 
> I can extend SaveDialogAction, but then I can't tell if the action succeeded 
> or
> not.
> 
> I created a custom command, but since SaveDialogAction is no
> AbstractCommandAction, I can't trigger it.
> 
> Can anyone help me how to approach this?
> 
> --
> Context is everything: http://forum.magnolia-
> cms.com/forum/thread.html?threadId=03557c87-00f6-479d-b51e-
> 3723f30f9d9d
> 
> 
> ----------------------------------------------------------------
> For list details, see http://www.magnolia-cms.com/community/mailing-
> lists.html
> Alternatively, use our forums: http://forum.magnolia-cms.com/
> To unsubscribe, E-mail to: <[email protected]>
> ----------------------------------------------------------------



----------------------------------------------------------------
For list details, see http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to