You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2017/05/16 07:11:57 UTC

[1/4] isis git commit: ISIS-1613: fixes no-arg actions, was hitting an NPE

Repository: isis
Updated Branches:
  refs/heads/ISIS-1613 0d79db970 -> 221047c7d


ISIS-1613: fixes no-arg actions, was hitting an NPE

... as the result of attempting to infer the current page from feedbackForm (that was null when no prompt).

Instead, have the FormExecutor ask for the page via its method (executeAndProcessResults).

This in turn requires building ActionParametersPanel's GUI using onInitialize() rather than constructor, so able to get hold of the panel's owning page so can pass down to the FormExecutor


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/0da818bb
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/0da818bb
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/0da818bb

Branch: refs/heads/ISIS-1613
Commit: 0da818bb6bdd701ed29da53d7c8506b81d7d1044
Parents: 0d79db9
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Mon May 15 22:46:34 2017 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Mon May 15 22:46:34 2017 +0100

----------------------------------------------------------------------
 .../wicket/model/models/FormExecutor.java       | 15 ++----
 .../ActionResultResponseType.java               | 13 ++---
 .../actions/ActionParametersFormExecutor.java   |  4 +-
 .../actions/ActionParametersPanel.java          | 15 ++++--
 .../wicket/ui/panels/FormExecutorAbstract.java  | 57 ++++++++++----------
 .../wicket/ui/panels/PromptFormAbstract.java    | 10 ++--
 6 files changed, 56 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/0da818bb/core/viewer-wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/FormExecutor.java
----------------------------------------------------------------------
diff --git a/core/viewer-wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/FormExecutor.java b/core/viewer-wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/FormExecutor.java
index 6eec674..57cac35 100644
--- a/core/viewer-wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/FormExecutor.java
+++ b/core/viewer-wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/FormExecutor.java
@@ -21,26 +21,19 @@ package org.apache.isis.viewer.wicket.model.models;
 
 import java.io.Serializable;
 
+import org.apache.wicket.Page;
 import org.apache.wicket.ajax.AjaxRequestTarget;
 import org.apache.wicket.markup.html.form.Form;
 
-import org.apache.isis.applib.annotation.PromptStyle;
-
 /**
  * Passed through the {@link ActionModel} or {@link ScalarModel}, allowing
  * two different Wicket UI components (eg owning <code>ActionPanel</code> and
  * <code>ActionParametersFormPanel</code> to interact.
- *
- * <p>
- *     REVIEW: this is a rather clunky design.  The executing panel
- *     isn't used by the model, and one panel is parent/creates of the other;
- *     is it necessary to decouple them to this degree?
- * </p>
  */
 public interface FormExecutor extends Serializable {
 
     boolean executeAndProcessResults(
-            AjaxRequestTarget target,
-            Form<?> feedbackForm,
-            PromptStyle promptStyle);
+            final Page page,
+            final AjaxRequestTarget targetIfAny,
+            final Form<?> feedbackFormIfAny);
 }

http://git-wip-us.apache.org/repos/asf/isis/blob/0da818bb/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/actionresponse/ActionResultResponseType.java
----------------------------------------------------------------------
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/actionresponse/ActionResultResponseType.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/actionresponse/ActionResultResponseType.java
index 8c79da6..15182d5 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/actionresponse/ActionResultResponseType.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/actionresponse/ActionResultResponseType.java
@@ -22,8 +22,10 @@ import java.util.List;
 import java.util.concurrent.Callable;
 
 import com.google.common.collect.Lists;
+
 import org.apache.wicket.ajax.AjaxRequestTarget;
 import org.apache.wicket.request.IRequestHandler;
+
 import org.apache.isis.applib.value.Blob;
 import org.apache.isis.applib.value.Clob;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
@@ -34,7 +36,6 @@ import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.core.runtime.system.session.IsisSessionFactory;
 import org.apache.isis.viewer.wicket.model.models.ActionModel;
 import org.apache.isis.viewer.wicket.model.models.EntityCollectionModel;
-import org.apache.isis.viewer.wicket.model.models.EntityModel;
 import org.apache.isis.viewer.wicket.model.models.ValueModel;
 import org.apache.isis.viewer.wicket.model.models.VoidModel;
 import org.apache.isis.viewer.wicket.ui.pages.entity.EntityPage;
@@ -171,15 +172,15 @@ public enum ActionResultResponseType {
 
     public static ActionResultResponse determineAndInterpretResult(
             final ActionModel model, 
-            final AjaxRequestTarget target, 
+            final AjaxRequestTarget targetIfAny,
             final ObjectAdapter resultAdapter) {
-        ActionResultResponseType arrt = determineFor(resultAdapter, target);
-        return arrt.interpretResult(model, target, resultAdapter);
+        ActionResultResponseType arrt = determineFor(resultAdapter, targetIfAny);
+        return arrt.interpretResult(model, targetIfAny, resultAdapter);
     }
 
     private static ActionResultResponseType determineFor(
             final ObjectAdapter resultAdapter, 
-            final AjaxRequestTarget target) {
+            final AjaxRequestTarget targetIfAny) {
         if(resultAdapter == null) {
             return ActionResultResponseType.VOID;
         }
@@ -195,7 +196,7 @@ public enum ActionResultResponseType {
                     return ActionResultResponseType.VALUE_BLOB;
                 } 
                 if(value instanceof java.net.URL) {
-                    return target != null? ActionResultResponseType.VALUE_URL_AJAX: ActionResultResponseType.VALUE_URL_NOAJAX;
+                    return targetIfAny != null? ActionResultResponseType.VALUE_URL_AJAX: ActionResultResponseType.VALUE_URL_NOAJAX;
                 } 
                 // else
                 return ActionResultResponseType.VALUE;

http://git-wip-us.apache.org/repos/asf/isis/blob/0da818bb/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actions/ActionParametersFormExecutor.java
----------------------------------------------------------------------
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actions/ActionParametersFormExecutor.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actions/ActionParametersFormExecutor.java
index 5ef362f..7462bca 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actions/ActionParametersFormExecutor.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actions/ActionParametersFormExecutor.java
@@ -56,9 +56,9 @@ public class ActionParametersFormExecutor extends FormExecutorAbstract<ActionMod
 
     protected void forwardOntoResult(
             final ObjectAdapter resultAdapter,
-            final AjaxRequestTarget target) {
+            final AjaxRequestTarget targetIfany) {
         ActionResultResponse resultResponse = ActionResultResponseType
-                .determineAndInterpretResult(model, target, resultAdapter);
+                .determineAndInterpretResult(model, targetIfany, resultAdapter);
         resultResponse.getHandlingStrategy().handleResults(resultResponse, getIsisSessionFactory());
     }
 

http://git-wip-us.apache.org/repos/asf/isis/blob/0da818bb/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actions/ActionParametersPanel.java
----------------------------------------------------------------------
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actions/ActionParametersPanel.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actions/ActionParametersPanel.java
index 9f0284a..bad909a 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actions/ActionParametersPanel.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actions/ActionParametersPanel.java
@@ -19,6 +19,7 @@
 
 package org.apache.isis.viewer.wicket.ui.components.actions;
 
+import org.apache.wicket.Page;
 import org.apache.wicket.markup.html.WebMarkupContainer;
 import org.apache.wicket.markup.html.basic.Label;
 import org.apache.wicket.model.Model;
@@ -62,7 +63,7 @@ public class ActionParametersPanel extends PanelAbstract<ActionModel> {
     public ActionParametersPanel(final String id, final ActionModel actionModel) {
         super(id, actionModel);
         actionModel.setFormExecutor(new ActionParametersFormExecutor(actionModel));
-        buildGui(getActionModel());
+        //buildGui(getActionModel());
     }
 
     /**
@@ -76,11 +77,16 @@ public class ActionParametersPanel extends PanelAbstract<ActionModel> {
         formExecutor.setActionPrompt(actionPrompt);
     }
 
+    @Override protected void onInitialize() {
+        super.onInitialize();
+
+        buildGui(getModel());
+    }
+
     @Override
     protected void onConfigure() {
         super.onConfigure();
 
-        buildGui(getModel());
     }
 
     private void buildGui(final ActionModel actionModel) {
@@ -145,8 +151,9 @@ public class ActionParametersPanel extends PanelAbstract<ActionModel> {
 
     private void buildGuiForNoParameters(final ActionModel formExecutor) {
 
-        boolean succeeded = formExecutor.getFormExecutor().executeAndProcessResults(null, null,
-                formExecutor.getPromptStyle());
+        final Page page = this.getPage();
+        boolean succeeded = formExecutor.getFormExecutor().executeAndProcessResults(page, null, null);
+
         if(succeeded) {
             // nothing to do
         } else {

http://git-wip-us.apache.org/repos/asf/isis/blob/0da818bb/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/FormExecutorAbstract.java
----------------------------------------------------------------------
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/FormExecutorAbstract.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/FormExecutorAbstract.java
index 863e04c..af208cc 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/FormExecutorAbstract.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/FormExecutorAbstract.java
@@ -13,7 +13,6 @@ import org.apache.wicket.markup.html.form.Form;
 import org.apache.wicket.util.visit.IVisit;
 import org.apache.wicket.util.visit.IVisitor;
 
-import org.apache.isis.applib.annotation.PromptStyle;
 import org.apache.isis.applib.services.command.Command;
 import org.apache.isis.applib.services.command.CommandContext;
 import org.apache.isis.applib.services.exceprecog.ExceptionRecognizer;
@@ -21,7 +20,6 @@ import org.apache.isis.applib.services.exceprecog.ExceptionRecognizerComposite;
 import org.apache.isis.applib.services.guice.GuiceBeanProvider;
 import org.apache.isis.applib.services.message.MessageService;
 import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.commons.authentication.MessageBroker;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.adapter.version.ConcurrencyException;
 import org.apache.isis.core.metamodel.facets.properties.renderunchanged.UnchangingFacet;
@@ -57,16 +55,16 @@ public abstract class FormExecutorAbstract<M extends BookmarkableModel<ObjectAda
 
     @Override
     public boolean executeAndProcessResults(
-            final AjaxRequestTarget target,
-            final Form<?> feedbackForm,
-            final PromptStyle promptStyle) {
+            final Page page,
+            final AjaxRequestTarget targetIfAny,
+            final Form<?> feedbackFormIfAny) {
 
         ObjectAdapter targetAdapter = null;
         try {
             targetAdapter = obtainTargetAdapter();
 
             // no concurrency exception, so continue...
-            return doExecuteAndProcessResults(target, feedbackForm, promptStyle);
+            return doExecuteAndProcessResults(page, targetIfAny, feedbackFormIfAny);
 
         } catch (ConcurrencyException ex) {
 
@@ -85,19 +83,21 @@ public abstract class FormExecutorAbstract<M extends BookmarkableModel<ObjectAda
     }
 
     /**
-     * @param target
+     *
+     * @param page
+     * @param targetIfAny
      * @return whether to clear args or not (they aren't if there was a validation exception)
      */
     private boolean doExecuteAndProcessResults(
-            final AjaxRequestTarget target,
-            final Form<?> feedbackForm,
-            final PromptStyle promptStyle) {
+            final Page page,
+            final AjaxRequestTarget targetIfAny,
+            final Form<?> feedbackFormIfAny) {
 
         // validate the action parameters (if any)
         final String invalidReasonIfAny = getReasonInvalidIfAny();
 
         if (invalidReasonIfAny != null) {
-            raiseWarning(target, feedbackForm, invalidReasonIfAny);
+            raiseWarning(targetIfAny, feedbackFormIfAny, invalidReasonIfAny);
             return false;
         }
 
@@ -127,18 +127,17 @@ public abstract class FormExecutorAbstract<M extends BookmarkableModel<ObjectAda
             targetEntityModel.resetVersion();
             targetEntityModel.resetPropertyModels();
 
-            onExecuteAndProcessResults(target);
+            onExecuteAndProcessResults(targetIfAny);
 
             final ObjectAdapter targetAdapter = targetEntityModel.load();
             final boolean redirectEvenIfSameObject = getSettings().isRedirectEvenIfSameObject();
 
-            if (targetAdapter != resultAdapter || redirectEvenIfSameObject) {
+            if (targetAdapter != resultAdapter || redirectEvenIfSameObject || targetIfAny == null) {
 
-                forwardOntoResult(resultAdapter, target);
+                forwardOntoResult(resultAdapter, targetIfAny);
 
             } else {
-
-                final Page page = feedbackForm.getPage();
+                final AjaxRequestTarget target = targetIfAny; // only in this branch if there *is* a target to use
                 addComponentsToRedraw(target, page);
             }
 
@@ -146,12 +145,12 @@ public abstract class FormExecutorAbstract<M extends BookmarkableModel<ObjectAda
 
         } catch (RuntimeException ex) {
 
-            String message = recognizeException(ex, target, feedbackForm);
+            String message = recognizeException(ex, targetIfAny, feedbackFormIfAny);
 
             if (message != null) {
                 // no need to add to message broker, should already have been added...
 
-                if (feedbackForm == null) {
+                if (feedbackFormIfAny == null) {
                     // forward on instead to void page
                     // (otherwise, we'll have rendered an action parameters page
                     // and so we'll be staying on that page)
@@ -171,10 +170,11 @@ public abstract class FormExecutorAbstract<M extends BookmarkableModel<ObjectAda
         }
     }
 
-    private void addComponentsToRedraw(final AjaxRequestTarget target, final Page page) {
+    private void addComponentsToRedraw(final AjaxRequestTarget target, final Page pageUNUSED) {
         final List<Component> componentsToRedraw = Lists.newArrayList();
         final List<Component> componentsNotToRedraw = Lists.newArrayList();
 
+        final Page page = target.getPage();
         page.visitChildren(new IVisitor<Component, Object>() {
             @Override
             public void component(final Component component, final IVisit<Object> visit) {
@@ -281,12 +281,17 @@ public abstract class FormExecutorAbstract<M extends BookmarkableModel<ObjectAda
         return recognizedErrorIfAny;
     }
 
-    private void raiseWarning(AjaxRequestTarget target, Form<?> feedbackForm, String error) {
-        if(target != null && feedbackForm != null) {
-            target.add(feedbackForm);
-            feedbackForm.error(error);
+    private void raiseWarning(
+            final AjaxRequestTarget targetIfAny,
+            final Form<?> feedbackFormIfAny,
+            final String error) {
+
+        if(targetIfAny != null && feedbackFormIfAny != null) {
+            targetIfAny.add(feedbackFormIfAny);
+            feedbackFormIfAny.error(error);
         } else {
-            getMessageBroker().addWarning(error);
+            final MessageService messageService = getServicesInjector().lookupService(MessageService.class);
+            messageService.warnUser(error);
         }
     }
 
@@ -311,10 +316,6 @@ public abstract class FormExecutorAbstract<M extends BookmarkableModel<ObjectAda
         return getPersistenceSession().getTransactionManager();
     }
 
-    private MessageBroker getMessageBroker() {
-        return getAuthenticationSession().getMessageBroker();
-    }
-
     protected IsisSessionFactory getIsisSessionFactory() {
         return IsisContext.getSessionFactory();
     }

http://git-wip-us.apache.org/repos/asf/isis/blob/0da818bb/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PromptFormAbstract.java
----------------------------------------------------------------------
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PromptFormAbstract.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PromptFormAbstract.java
index 1a11d73..797447f 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PromptFormAbstract.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PromptFormAbstract.java
@@ -89,10 +89,8 @@ public abstract class PromptFormAbstract<T extends IModel<ObjectAdapter> & FormE
 
     protected AjaxButton addOkButton() {
 
-//        final IModel<ObjectAdapter> model = getModel();
-
         AjaxButton okButton = settings.isUseIndicatorForFormSubmit()
-                ? new IndicatingAjaxButton(ID_OK_BUTTON, new ResourceModel("okLabel")) {
+        ? new IndicatingAjaxButton(ID_OK_BUTTON, new ResourceModel("okLabel")) {
             private static final long serialVersionUID = 1L;
 
             @Override
@@ -104,8 +102,6 @@ public abstract class PromptFormAbstract<T extends IModel<ObjectAdapter> & FormE
                 }
 
                 onSubmitOf(target, form, this);
-
-
             }
 
             @Override
@@ -122,7 +118,7 @@ public abstract class PromptFormAbstract<T extends IModel<ObjectAdapter> & FormE
                 target.add(form);
             }
         }
-                : new AjaxButton(ID_OK_BUTTON, new ResourceModel("okLabel")) {
+        : new AjaxButton(ID_OK_BUTTON, new ResourceModel("okLabel")) {
             private static final long serialVersionUID = 1L;
 
             @Override
@@ -225,7 +221,7 @@ public abstract class PromptFormAbstract<T extends IModel<ObjectAdapter> & FormE
 
         final PromptStyle promptStyle = formExecutorContext.getPromptStyle();
         boolean succeeded = formExecutorContext.getFormExecutor()
-                .executeAndProcessResults(target, form, promptStyle);
+                .executeAndProcessResults(target.getPage(), target, form);
         if (succeeded) {
             if (promptStyle == PromptStyle.DIALOG) {
                 // the Wicket ajax callbacks will have just started to hide the veil


[2/4] isis git commit: ISIS-1613: fixes NPE with bulk actions

Posted by da...@apache.org.
ISIS-1613: fixes NPE with bulk actions

which was resulting from the actionModel hint, which holds the action to invoke to recreate the list of domain objects, was caching its results and so was returning a list of stale pojos that were implicitly detached and therefore mapped as transient.

Fix was simply to invalidate this cached return result by invalidating the actionModel.


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/295e67f4
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/295e67f4
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/295e67f4

Branch: refs/heads/ISIS-1613
Commit: 295e67f4d31425cb1af98a10716b206948cd3cc0
Parents: 0da818b
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Mon May 15 23:01:10 2017 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Mon May 15 23:01:10 2017 +0100

----------------------------------------------------------------------
 .../ui/components/collection/bulk/BulkActionsLinkFactory.java       | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/295e67f4/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/bulk/BulkActionsLinkFactory.java
----------------------------------------------------------------------
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/bulk/BulkActionsLinkFactory.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/bulk/BulkActionsLinkFactory.java
index 174bc3f..b97b572 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/bulk/BulkActionsLinkFactory.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/bulk/BulkActionsLinkFactory.java
@@ -156,6 +156,7 @@ public final class BulkActionsLinkFactory implements ActionLinkFactory {
 
                     final ActionModel actionModel = model.getActionModelHint();
                     if(actionModel != null && actionModel.getActionMemento().getAction(getSpecificationLoader()).getSemantics().isIdempotentInNature()) {
+                        actionModel.detach(); // force reload
                         ObjectAdapter resultAdapter = actionModel.getObject();
                         model.setObjectList(resultAdapter);
                     } else {


[4/4] isis git commit: ISIS-1613: comment out call to isisShowVeil...

Posted by da...@apache.org.
ISIS-1613: comment out call to isisShowVeil...

... throwing a Javascript error, and may not be needed anyway with the new design


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/221047c7
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/221047c7
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/221047c7

Branch: refs/heads/ISIS-1613
Commit: 221047c7db332affbabbfee34e06a86e4bd39243
Parents: de39ef6
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Tue May 16 08:10:04 2017 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Tue May 16 08:10:04 2017 +0100

----------------------------------------------------------------------
 .../apache/isis/viewer/wicket/ui/panels/PromptFormAbstract.java | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/221047c7/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PromptFormAbstract.java
----------------------------------------------------------------------
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PromptFormAbstract.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PromptFormAbstract.java
index 797447f..054ad2d 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PromptFormAbstract.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PromptFormAbstract.java
@@ -227,7 +227,10 @@ public abstract class PromptFormAbstract<T extends IModel<ObjectAdapter> & FormE
                 // the Wicket ajax callbacks will have just started to hide the veil
                 // we now show it once more, so that a veil continues to be shown until the
                 // new page is rendered.
-                target.appendJavaScript("isisShowVeil();\n");
+
+                // REVIEW: commenting out, this is throwing a javascript error (function not defined).
+                // in any case, with the new design (of not forwarding unless necessary), not certain it's needed.
+                // target.appendJavaScript("isisShowVeil();\n");
             }
 
             okButton.send(getPage(), Broadcast.EXACT, newCompletedEvent(target, form));


[3/4] isis git commit: ISIS-1613: workaround for fact that blobs/clobs do not correctly repaint.

Posted by da...@apache.org.
ISIS-1613: workaround for fact that blobs/clobs do not correctly repaint.

For these, force a redraw by just forwarding to page


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/de39ef6c
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/de39ef6c
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/de39ef6c

Branch: refs/heads/ISIS-1613
Commit: de39ef6c66e8461c0fa1e827e8553578d3b8cefd
Parents: 295e67f
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Tue May 16 08:09:22 2017 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Tue May 16 08:09:22 2017 +0100

----------------------------------------------------------------------
 .../wicket/ui/panels/FormExecutorAbstract.java  | 43 +++++++++++++++++---
 1 file changed, 38 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/de39ef6c/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/FormExecutorAbstract.java
----------------------------------------------------------------------
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/FormExecutorAbstract.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/FormExecutorAbstract.java
index af208cc..28a452c 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/FormExecutorAbstract.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/FormExecutorAbstract.java
@@ -36,6 +36,7 @@ import org.apache.isis.viewer.wicket.model.models.FormExecutor;
 import org.apache.isis.viewer.wicket.model.models.ParentEntityModelProvider;
 import org.apache.isis.viewer.wicket.model.models.ScalarModel;
 import org.apache.isis.viewer.wicket.ui.actionresponse.ActionResultResponseHandlingStrategy;
+import org.apache.isis.viewer.wicket.ui.components.scalars.isisapplib.IsisBlobOrClobPanelAbstract;
 
 public abstract class FormExecutorAbstract<M extends BookmarkableModel<ObjectAdapter> & ParentEntityModelProvider>
         implements FormExecutor {
@@ -130,15 +131,13 @@ public abstract class FormExecutorAbstract<M extends BookmarkableModel<ObjectAda
             onExecuteAndProcessResults(targetIfAny);
 
             final ObjectAdapter targetAdapter = targetEntityModel.load();
-            final boolean redirectEvenIfSameObject = getSettings().isRedirectEvenIfSameObject();
-
-            if (targetAdapter != resultAdapter || redirectEvenIfSameObject || targetIfAny == null) {
+            if (shouldForward(page, resultAdapter, targetAdapter) || targetIfAny == null) {
 
                 forwardOntoResult(resultAdapter, targetIfAny);
 
             } else {
                 final AjaxRequestTarget target = targetIfAny; // only in this branch if there *is* a target to use
-                addComponentsToRedraw(target, page);
+                addComponentsToRedraw(target);
             }
 
             return true;
@@ -170,7 +169,41 @@ public abstract class FormExecutorAbstract<M extends BookmarkableModel<ObjectAda
         }
     }
 
-    private void addComponentsToRedraw(final AjaxRequestTarget target, final Page pageUNUSED) {
+    private boolean shouldForward(
+            final Page page,
+            final ObjectAdapter resultAdapter,
+            final ObjectAdapter targetAdapter) {
+        if (shouldForward(resultAdapter, targetAdapter)) {
+            return true;
+        }
+
+        // this is a bit of a hack... currently the blob/clob panel doesn't correctly redraw itself.
+        // we therefore force a reforward (unless is declared as unchanging).
+        final Object hasBlobsOrClobs = page.visitChildren(IsisBlobOrClobPanelAbstract.class,
+                new IVisitor<IsisBlobOrClobPanelAbstract, Object>() {
+                    @Override
+                    public void component(final IsisBlobOrClobPanelAbstract object, final IVisit<Object> visit) {
+                        if (!isUnchanging(object)) {
+                            visit.stop(true);
+                        }
+                    }
+
+                    private boolean isUnchanging(final IsisBlobOrClobPanelAbstract object) {
+                        final ScalarModel scalarModel = (ScalarModel) object.getModel();
+                        final UnchangingFacet unchangingFacet = scalarModel.getFacet(UnchangingFacet.class);
+                        return unchangingFacet != null && unchangingFacet.value();
+                    }
+
+                });
+        return hasBlobsOrClobs != null;
+    }
+
+    private boolean shouldForward(final ObjectAdapter resultAdapter, final ObjectAdapter targetAdapter) {
+        final boolean redirectEvenIfSameObject = getSettings().isRedirectEvenIfSameObject();
+        return targetAdapter != resultAdapter || redirectEvenIfSameObject;
+    }
+
+    private void addComponentsToRedraw(final AjaxRequestTarget target) {
         final List<Component> componentsToRedraw = Lists.newArrayList();
         final List<Component> componentsNotToRedraw = Lists.newArrayList();