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/07/24 16:41:01 UTC

[02/11] isis git commit: ISIS-1667: refactors ActionParametersPanel and FormExecutorAbstract to understand flow better

ISIS-1667: refactors ActionParametersPanel and FormExecutorAbstract to understand flow better

specifically:
- inlined some methods in ActionParametersFormExecutor
- comments to FormExecutorAbstract (is all)
- renamed local vars in ActionParametersPanel (is all)


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

Branch: refs/heads/master
Commit: 19ff4afb18143848d89e5dfdc5ec7c699844dc15
Parents: 61fb1e5
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Mon Jul 24 15:32:53 2017 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Mon Jul 24 15:32:53 2017 +0100

----------------------------------------------------------------------
 .../actions/ActionParametersFormExecutor.java   | 20 ++----------
 .../actions/ActionParametersPanel.java          | 24 ++++++++++++---
 .../wicket/ui/panels/FormExecutorAbstract.java  | 32 ++++++++++++--------
 3 files changed, 42 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/19ff4afb/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 a77beef..d1134d8 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
@@ -6,7 +6,6 @@ import org.apache.wicket.ajax.AjaxRequestTarget;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.viewer.wicket.model.models.ActionModel;
 import org.apache.isis.viewer.wicket.model.models.ActionPrompt;
-import org.apache.isis.viewer.wicket.model.models.BookmarkableModel;
 import org.apache.isis.viewer.wicket.model.models.BookmarkedPagesModel;
 import org.apache.isis.viewer.wicket.ui.actionresponse.ActionResultResponse;
 import org.apache.isis.viewer.wicket.ui.actionresponse.ActionResultResponseType;
@@ -31,7 +30,9 @@ public class ActionParametersFormExecutor extends FormExecutorAbstract<ActionMod
     protected void onExecuteAndProcessResults(final AjaxRequestTarget target) {
 
         if (model.isBookmarkable()) {
-            bookmarkPage(model);
+            BookmarkedPagesModelProvider application = (BookmarkedPagesModelProvider) Session.get();
+            BookmarkedPagesModel bookmarkedPagesModel = application.getBookmarkedPagesModel();
+            bookmarkedPagesModel.bookmarkPage(model);
         }
 
         if (actionPrompt != null) {
@@ -54,21 +55,6 @@ public class ActionParametersFormExecutor extends FormExecutorAbstract<ActionMod
         resultResponse.getHandlingStrategy().handleResults(resultResponse, getIsisSessionFactory());
     }
 
-    ///////////////////////////////////////////////////////
-
-    protected void bookmarkPage(BookmarkableModel<?> model) {
-        getBookmarkedPagesModel().bookmarkPage(model);
-    }
-
-    private BookmarkedPagesModel getBookmarkedPagesModel() {
-        BookmarkedPagesModelProvider application = (BookmarkedPagesModelProvider) getSession();
-        return application.getBookmarkedPagesModel();
-    }
-
-    Session getSession() {
-        return Session.get();
-    }
-
 
     ///////////////////////////////////////////////////////
     // Dependencies (from context)

http://git-wip-us.apache.org/repos/asf/isis/blob/19ff4afb/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 e91eac6..9a380bf 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
@@ -86,23 +86,34 @@ public class ActionParametersPanel extends PanelAbstract<ActionModel> {
     protected void onInitialize() {
         super.onInitialize();
 
+
+        //
+        // <div wicket:id="header" class="iconAndTitle panel panel-default actionPanelHeaderNew">
+        //   <wicket:container wicket:id="entityIconAndTitle">[icon and title]</wicket:container>
+        //   <h3 wicket:id="actionName" class="actionName">[action name]</h3>
+        // </div>
+        // <div wicket:id="parameters"></div>
+        //
+
+
         // buildGui(getModel());
         final ActionModel actionModel = getModel();
+
         if (actionModel.hasParameters()) {
+
             // buildGuiForParameters(getActionModel());
-            final ActionModel actionModel1 = getActionModel();
 
             WebMarkupContainer header = addHeader();
 
             ObjectAdapter targetAdapter = null;
             try {
-                targetAdapter = actionModel1.getTargetAdapter();
+                targetAdapter = actionModel.getTargetAdapter();
 
                 getComponentFactoryRegistry().addOrReplaceComponent(this, ComponentType.PARAMETERS, getActionModel());
-                getComponentFactoryRegistry().addOrReplaceComponent(header, ComponentType.ENTITY_ICON_AND_TITLE, actionModel1
+                getComponentFactoryRegistry().addOrReplaceComponent(header, ComponentType.ENTITY_ICON_AND_TITLE, actionModel
                         .getParentEntityModel());
 
-                final String actionName = getActionModel().getActionMemento().getAction(actionModel1.getSpecificationLoader()).getName();
+                final String actionName = getActionModel().getActionMemento().getAction(actionModel.getSpecificationLoader()).getName();
                 header.add(new Label(ID_ACTION_NAME, Model.of(actionName)));
 
             } catch (final ConcurrencyException ex) {
@@ -124,8 +135,11 @@ public class ActionParametersPanel extends PanelAbstract<ActionModel> {
             // buildGuiForNoParameters(actionModel);
 
             final Page page = this.getPage();
-            boolean succeeded = actionModel.getFormExecutor().executeAndProcessResults(page, null, null);
 
+            // returns false - if invalid args; if concurrency exception;
+            // returns true - if redirecting to new page, or repainting all components.
+
+            boolean succeeded = actionModel.getFormExecutor().executeAndProcessResults(page, null, null);
             if(succeeded) {
                 // nothing to do
             } else {

http://git-wip-us.apache.org/repos/asf/isis/blob/19ff4afb/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 f8a0301..d19d4a2 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
@@ -69,6 +69,14 @@ public abstract class FormExecutorAbstract<M extends BookmarkableModel<ObjectAda
         return guiceBeanProvider.lookup(WicketViewerSettings.class);
     }
 
+    /**
+     *
+     * @param page
+     * @param targetIfAny
+     * @param feedbackFormIfAny
+     *
+     * @return <tt>false</tt> - if invalid args; if concurrency exception; <tt>true</tt> if redirecting to new page, or repainting all components
+     */
     @Override
     public boolean executeAndProcessResults(
             final Page page,
@@ -83,7 +91,7 @@ public abstract class FormExecutorAbstract<M extends BookmarkableModel<ObjectAda
         try {
 
             // may immediately throw a concurrency exception if
-            // the Isis Oid held in the underlying EntityModel is stale w.r.t. the the DB.
+            // the Isis Oid held in the underlying EntityModel is stale w.r.t. the DB.
             targetAdapter = obtainTargetAdapter();
 
             // no concurrency exception, so continue...
@@ -286,17 +294,17 @@ public abstract class FormExecutorAbstract<M extends BookmarkableModel<ObjectAda
         // but trying to preserve them seems to cause the 302 redirect to be swallowed somehow
         final EntityPage entityPage =
 
-                // disabling concurrency checking after the layout XML (grid) feature
-                // was throwing an exception when rebuild grid after invoking action
-                // not certain why that would be the case, but think it should be
-                // safe to simply disable while recreating the page to re-render back to user.
-                AdapterManager.ConcurrencyChecking.executeWithConcurrencyCheckingDisabled(
-                        new Callable<EntityPage>() {
-                            @Override public EntityPage call() throws Exception {
-                                return new EntityPage(targetAdapter, ex);
-                            }
-                        }
-                );
+        // disabling concurrency checking after the layout XML (grid) feature
+        // was throwing an exception when rebuild grid after invoking action
+        // not certain why that would be the case, but think it should be
+        // safe to simply disable while recreating the page to re-render back to user.
+        AdapterManager.ConcurrencyChecking.executeWithConcurrencyCheckingDisabled(
+                new Callable<EntityPage>() {
+                    @Override public EntityPage call() throws Exception {
+                        return new EntityPage(targetAdapter, ex);
+                    }
+                }
+        );
 
         // force any changes in state etc to happen now prior to the redirect;
         // in the case of an object being returned, this should cause our page mementos