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

dklco pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-app-cms.git

commit 3428556edca93fd33e2e27b49c6820ecfa60d0b0
Author: Dan Klco <[email protected]>
AuthorDate: Thu Jan 28 09:53:18 2021 -0500

    SLING-10083 Adding the UCG Path as a variable to enable redirecting to the 
new UGC resource on success
---
 .../java/org/apache/sling/cms/reference/forms/impl/FormHandler.java   | 4 ++--
 .../cms/reference/forms/impl/actions/UserGeneratedContentAction.java  | 2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git 
a/reference/src/main/java/org/apache/sling/cms/reference/forms/impl/FormHandler.java
 
b/reference/src/main/java/org/apache/sling/cms/reference/forms/impl/FormHandler.java
index 66feb4f..af21442 100644
--- 
a/reference/src/main/java/org/apache/sling/cms/reference/forms/impl/FormHandler.java
+++ 
b/reference/src/main/java/org/apache/sling/cms/reference/forms/impl/FormHandler.java
@@ -86,7 +86,6 @@ public class FormHandler extends SlingAllMethodsServlet {
             log.debug("Loading fields...");
             boolean fieldsLoadSucceeded = ((FormRequestImpl) 
formRequest).initFields();
             sub = new StringSubstitutor(formRequest.getFormData());
-            successPage = sub.replace(properties.get("successPage", pagePath));
             errorPage = sub.replace(properties.get("errorPage", pagePath));
             if (!fieldsLoadSucceeded) {
                 log.warn("Field initialization failed, check logs");
@@ -97,6 +96,7 @@ public class FormHandler extends SlingAllMethodsServlet {
 
             log.debug("Calling actions...");
             callActions(request, formRequest);
+            successPage = sub.replace(properties.get("successPage", pagePath));
             request.getSession().removeAttribute(formRequest.getSessionId());
         } catch (FormException e) {
             log.warn("Exception executing actions", e);
@@ -117,7 +117,7 @@ public class FormHandler extends SlingAllMethodsServlet {
                 response.sendRedirect(resolveUrl(request, successPage, 
"message=success"));
             }
         } else {
-            response.sendRedirect(resolveUrl(request, successPage, 
"message=success"));
+            response.sendRedirect(resolveUrl(request, pagePath, 
"message=success"));
         }
     }
 
diff --git 
a/reference/src/main/java/org/apache/sling/cms/reference/forms/impl/actions/UserGeneratedContentAction.java
 
b/reference/src/main/java/org/apache/sling/cms/reference/forms/impl/actions/UserGeneratedContentAction.java
index fb5fa17..c8990b9 100644
--- 
a/reference/src/main/java/org/apache/sling/cms/reference/forms/impl/actions/UserGeneratedContentAction.java
+++ 
b/reference/src/main/java/org/apache/sling/cms/reference/forms/impl/actions/UserGeneratedContentAction.java
@@ -115,6 +115,8 @@ public class UserGeneratedContentAction implements 
FormAction {
 
             resolver.commit();
             log.debug("Successfully persisted UGC");
+
+            request.getFormData().put("ugcPath", container.getPath());
             return FormActionResult.success("Created UGC Item");
         } catch (PersistenceException e) {
             throw new FormException("Failed to create UGC Content", e);

Reply via email to