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 2021/05/28 12:32:33 UTC

[isis] branch ISIS-2710 created (now 3aa68ba)

This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a change to branch ISIS-2710
in repository https://gitbox.apache.org/repos/asf/isis.git.


      at 3aa68ba  ISIS-2710: short-circuits check for redirectPolicy

This branch includes the following new commits:

     new 3aa68ba  ISIS-2710: short-circuits check for redirectPolicy

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[isis] 01/01: ISIS-2710: short-circuits check for redirectPolicy

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch ISIS-2710
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 3aa68ba95ed88de20f375dea0a7e284101e1cd77
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Fri May 28 13:32:00 2021 +0100

    ISIS-2710: short-circuits check for redirectPolicy
    
    ... to avoid resetting entity model if it won't be needed.  This also enables a workaround of annotating a delete action of a view model (wrapping an entity that is deleted during the action).
---
 .../wicket/ui/panels/FormExecutorDefault.java      | 32 +++++++++++++++++-----
 1 file changed, 25 insertions(+), 7 deletions(-)

diff --git a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/FormExecutorDefault.java b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/FormExecutorDefault.java
index dd73ede..d0c495a 100644
--- a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/FormExecutorDefault.java
+++ b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/FormExecutorDefault.java
@@ -131,11 +131,23 @@ implements FormExecutor {
             //
             val resultAdapter = obtainResultAdapter();
 
-            // flush any queued changes; any concurrency or violation exceptions will actually be thrown here
+            val redirectFacet =  model instanceof ActionModel
+                ? ((ActionModel) model).getMetaModel().getFacet(RedirectFacet.class)
+                : null;
+
             if(commonContext.getInteractionTracker().isInInteraction()) {
+
+                // flush any queued changes; any concurrency or violation exceptions will actually be thrown here
                 commonContext.getTransactionService().flushTransaction();
 
-                if(EntityUtil.isDestroyed(targetAdapter)) {
+                // TODO: REVIEW: I wonder why this next block is only performed within the outer if block?
+                //  my guess is that the if block is always evaluated, in which case this is always run.
+
+                if(willDefinitelyRedirect(redirectFacet)) {
+                    // should circuit the redirect check later on; there's no need to reset the adapter
+                    // (this also provides a workaround for view models wrapping now-deleted entities)
+                    targetAdapter = ManagedObject.empty(targetAdapter.getSpecification());
+                } else if(EntityUtil.isDestroyed(targetAdapter)) {
                     // if this was an entity delete action
                     // then we don't re-fetch / re-create the targetAdapter
                     targetAdapter = ManagedObject.empty(targetAdapter.getSpecification());
@@ -149,10 +161,6 @@ implements FormExecutor {
             // hook to close prompt etc.
             onExecuteAndProcessResults(targetIfAny);
 
-            val redirectFacet =  model instanceof ActionModel
-                ? ((ActionModel) model).getMetaModel().getFacet(RedirectFacet.class)
-                : null;
-
             if (shouldRedirect(targetAdapter, resultAdapter, redirectFacet)
                     || hasBlobsOrClobs(page)
                     || targetIfAny == null) {
@@ -210,6 +218,16 @@ implements FormExecutor {
             final ManagedObject resultAdapter,
             final RedirectFacet redirectFacet) {
 
+        if(willDefinitelyRedirect(redirectFacet)) {
+            return true;
+        }
+
+        return differs(targetAdapter, resultAdapter);
+    }
+
+    private boolean willDefinitelyRedirect(
+            final RedirectFacet redirectFacet) {
+
         if(redirectFacet == null) {
             return getSettings().isRedirectEvenIfSameObject();
         }
@@ -228,7 +246,7 @@ implements FormExecutor {
             // fall through to...
 
         case ONLY_IF_DIFFERS:
-            return differs(targetAdapter, resultAdapter);
+            return false;
         }
     }