/DefaultEditorActionRenderer.diff Secret
Created
April 6, 2016 07:36
Star
You must be signed in to star a gist
check validity *before* firing the action, otherwise session can be saved and thus validators might be affected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- a/magnolia-ui-dialog/src/main/java/info/magnolia/ui/dialog/actionarea/renderer/DefaultEditorActionRenderer.java | |
| +++ b/magnolia-ui-dialog/src/main/java/info/magnolia/ui/dialog/actionarea/renderer/DefaultEditorActionRenderer.java | |
| @@ -64,12 +64,19 @@ public class DefaultEditorActionRenderer implements ActionRenderer { | |
| ClickListener clickListener = new ClickListener() { | |
| @Override | |
| public void buttonClick(ClickEvent event) { | |
| - listener.onActionFired(name, new HashMap<String, Object>()); | |
| - // make sure we don't trigger useless validation for all form fields when the action is 'cancel'. | |
| - if (!BaseDialog.CANCEL_ACTION_NAME.equals(name) && listener instanceof EditorValidator && !((EditorValidator) listener).isValid()) { | |
| - // have to re-enable button since validation failed | |
| - button.setEnabled(true); | |
| + // don't trigger validation for all fields when the action is 'cancel'. | |
| + if (!BaseDialog.CANCEL_ACTION_NAME.equals(name)) { | |
| + // check validity *before* firing the action, otherwise session can be saved and thus validators might be affected | |
| + // TODO: well ideally, we shouldn't check validation at all here though (only validate once in the save action) | |
| + boolean isValid = !(listener instanceof EditorValidator) || ((EditorValidator) listener).isValid(); | |
| + System.out.println("ACTION RENDERER: " + (isValid ? "VALID" : "NOT VALID")); | |
| + if (!isValid) { | |
| + // validation will fail, so re-enable that button | |
| + button.setEnabled(true); | |
| + } | |
| } | |
| + | |
| + listener.onActionFired(name, new HashMap<String, Object>()); | |
| } | |
| }; | |
| this.button = new Button(label, clickListener); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment