[BLOSSOM-14] Make possible to set a SaveHandler for a dialog. Created: 15/Sep/10  Updated: 06/Dec/14  Resolved: 23/Dec/10

Status: Closed
Project: Blossom
Component/s: None
Affects Version/s: None
Fix Version/s: 1.2

Type: New Feature Priority: Major
Reporter: Danilo Ghirardelli Assignee: Tobias Mattsson
Resolution: Fixed Votes: 0
Labels: saveHandler
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File saveHandler.patch    
Issue Links:
relation
is related to MAGNOLIA-3299 Make "saveHandler" property properly ... Closed
Template:
Patch included:
Yes
Acceptance criteria:
Empty
Date of First Response:

 Description   

It would be nice to have the possibility to set a saveHandler class also for Blossom-instantiated paragraphs.
I didn't found a way to use a method of the controller as saveHandler, because the SaveHandler class seems to require a bit of initialization and settings, but maybe I just can't see an easy way to do it.
Instead, the attached patch adds the @SaveHandler(class) annotation to the Blossom ones, making possible to set the SaveHandler class for the paragraph/dialogFactory.

A few notes:

  • I don't know if it's preferrable to have a new annotation or add a field in the existing ones. My preference would have been to add a field, but I thought you'd prefer the new annotation.
  • I'm not sure that the saveHandler is strictly needed also in the ParagraphDescription, but I added it anyway.
  • Setting the saveHandler in the dialog seems either buggy or incomprehensible to me: even forcing it in the dialog config (in the DefaultDialogCreator) would not have effect because configNode is null, so I had to override the getSaveHandler() method.
  • Ovveride the getSaveHandler() as it is was really an ugly pacth. I opened MAGNOLIA-3299 because as it is now, the only way to set a saveHandler with fallback to the default be using reflections.
  • Patch works fine for me but honestly I didn't test it with all use cases.


 Comments   
Comment by Tobias Mattsson [ 20/Dec/10 ]

Thanks Danilo for your extensive research on this. I'm implementing this feature now. It will be used like this:

@InitSaveHandler
public SaveHandler initSaveHandler()

{...}

It follows the design of Springs @InitBinder for initializing a WebDataBinder.

Feedback is more than welcome!

Comment by Danilo Ghirardelli [ 20/Dec/10 ]

I suppose this will be used directly in the controller, no?
Do you plan to use the Controller itself as a saveHandler instance? I suppose this will not be denied by the proposed method, but could be a real mess of code if someone uses it that way...

Do you plan to take a look into MAGNOLIA-3299 anyway?

Comment by Tobias Mattsson [ 21/Dec/10 ]

The @InitSaveHandler method can provide a save handler in any way it wants. In most cases that would mean instantiating a specific class and then do configuration of the instance specifically for its dialog/paragraph.

Blossom needs to support Magnolia 4.1+ so it will still have the workaround for MAGNOLIA-3299 when it's fixed.

Comment by Jan Haderka [ 06/Dec/14 ]

Bulk close of old resolved issues.

Generated at Sun Feb 11 23:29:16 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.