You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by dk...@apache.org on 2019/07/25 04:38:39 UTC

[sling-org-apache-sling-app-cms] branch dklco/form-framework updated (2a8051a -> 65d808b)

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

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


    from 2a8051a  Adding initial commit of the form framework
     new 0d805cb  Fixing test issues
     new 65d808b  Fixing issue with the parent path for the policy query

The 2 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.


Summary of changes:
 .../sling/cms/reference/forms/impl/FormRequestImpl.java    | 14 ++++++++------
 .../sling/cms/reference/form/impl/FormRequestImplTest.java |  2 +-
 reference/src/test/resources/form.json                     |  8 ++++++++
 .../components/caconfig/scripts/policyOptions.jsp          |  4 +++-
 4 files changed, 20 insertions(+), 8 deletions(-)


[sling-org-apache-sling-app-cms] 01/02: Fixing test issues

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

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

commit 0d805cbc1855f0343f83fa7930fa3c5f92b70ac9
Author: Dan Klco <dk...@apache.org>
AuthorDate: Thu Jul 25 00:37:55 2019 -0400

    Fixing test issues
---
 .../sling/cms/reference/forms/impl/FormRequestImpl.java    | 14 ++++++++------
 .../sling/cms/reference/form/impl/FormRequestImplTest.java |  2 +-
 reference/src/test/resources/form.json                     |  8 ++++++++
 .../components/caconfig/scripts/policyOptions.jsp          |  2 +-
 4 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/reference/src/main/java/org/apache/sling/cms/reference/forms/impl/FormRequestImpl.java b/reference/src/main/java/org/apache/sling/cms/reference/forms/impl/FormRequestImpl.java
index a5bcef3..c07cc2b 100644
--- a/reference/src/main/java/org/apache/sling/cms/reference/forms/impl/FormRequestImpl.java
+++ b/reference/src/main/java/org/apache/sling/cms/reference/forms/impl/FormRequestImpl.java
@@ -86,16 +86,18 @@ public class FormRequestImpl implements FormRequest {
         if (request.getSession().getAttribute(this.getSessionId()) != null) {
             formData.putAll(((Map<String, Object>) request.getSession().getAttribute(this.getSessionId())));
         }
-        if (this.loadProviders) {
+        if (this.loadProviders && getFormResource().getChild("providers") != null) {
             List<Resource> providers = ResourceTree.stream(getFormResource().getChild("providers"))
                     .map(ResourceTree::getResource).collect(Collectors.toList());
             for (Resource provider : providers) {
                 log.debug("Looking for handler for: {}", provider);
-                for (FormValueProvider fvp : formValueProvider) {
-                    if (fvp.handles(provider)) {
-                        log.debug("Invoking field value provider: {}", fvp.getClass());
-                        fvp.loadValues(provider, formData);
-                        break;
+                if (formValueProvider != null) {
+                    for (FormValueProvider fvp : formValueProvider) {
+                        if (fvp.handles(provider)) {
+                            log.debug("Invoking field value provider: {}", fvp.getClass());
+                            fvp.loadValues(provider, formData);
+                            break;
+                        }
                     }
                 }
             }
diff --git a/reference/src/test/java/org/apache/sling/cms/reference/form/impl/FormRequestImplTest.java b/reference/src/test/java/org/apache/sling/cms/reference/form/impl/FormRequestImplTest.java
index 35754b6..e473beb 100644
--- a/reference/src/test/java/org/apache/sling/cms/reference/form/impl/FormRequestImplTest.java
+++ b/reference/src/test/java/org/apache/sling/cms/reference/form/impl/FormRequestImplTest.java
@@ -59,7 +59,7 @@ public class FormRequestImplTest {
         FieldSetter.setField(formRequest, formRequest.getClass().getDeclaredField("fieldHandlers"),
                 Arrays.asList(new SelectionHandler(), new TextareaHandler(), new TextfieldHandler()));
 
-        formRequest.init();
+        formRequest.initFields();
     }
 
     @Test
diff --git a/reference/src/test/resources/form.json b/reference/src/test/resources/form.json
index c571b1c..dbe3595 100644
--- a/reference/src/test/resources/form.json
+++ b/reference/src/test/resources/form.json
@@ -149,6 +149,14 @@
                         "subpath": "jobprofile",
                         "sling:resourceType": "reference/components/forms/actions/updateprofile"
                     }
+                },
+                "providers": {
+                    "jcr:primaryType": "nt:unstructured",
+                    "userprofile": {
+                        "jcr:primaryType": "nt:unstructured",
+                        "sling:resourceType": "reference/components/forms/providers/userprofile",
+                        "subpath": "jobprofile"
+                    }
                 }
             }
         }
diff --git a/ui/src/main/resources/jcr_root/libs/sling-cms/components/caconfig/scripts/policyOptions.jsp b/ui/src/main/resources/jcr_root/libs/sling-cms/components/caconfig/scripts/policyOptions.jsp
index 83d995c..9c82aa8 100644
--- a/ui/src/main/resources/jcr_root/libs/sling-cms/components/caconfig/scripts/policyOptions.jsp
+++ b/ui/src/main/resources/jcr_root/libs/sling-cms/components/caconfig/scripts/policyOptions.jsp
@@ -18,7 +18,7 @@
  */ --%>
  <%@include file="/libs/sling-cms/global.jsp"%>
 <option value="">Select Policy</option>
-<sling:getParent var="parent" resource="${slingRequest.requestPathInfo.suffixResource}" level="4" />
+<sling:getParent var="parent" resource="${slingRequest.requestPathInfo.suffixResource}" level="2" />
 <c:set var="query" value="SELECT * FROM [nt:unstructured] WHERE [sling:resourceType] = 'sling-cms/components/caconfig/policy' AND ISDESCENDANTNODE([${parent.path}]) ORDER BY [jcr:title]" />
 <c:forEach var="policy" items="${sling:findResources(resourceResolver,query,'JCR-SQL2')}">
     <option value="${policy.path}" ${policy.path == editProperties.policyPath ? 'selected' : ''}><sling:encode value="${policy.valueMap['jcr:title']}" mode="HTML" /></option>


[sling-org-apache-sling-app-cms] 02/02: Fixing issue with the parent path for the policy query

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

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

commit 65d808b3018eb9919d5f30e53fb1b22a95958c0f
Author: Dan Klco <dk...@apache.org>
AuthorDate: Thu Jul 25 00:38:29 2019 -0400

    Fixing issue with the parent path for the policy query
---
 .../libs/sling-cms/components/caconfig/scripts/policyOptions.jsp        | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/ui/src/main/resources/jcr_root/libs/sling-cms/components/caconfig/scripts/policyOptions.jsp b/ui/src/main/resources/jcr_root/libs/sling-cms/components/caconfig/scripts/policyOptions.jsp
index 9c82aa8..7bf8257 100644
--- a/ui/src/main/resources/jcr_root/libs/sling-cms/components/caconfig/scripts/policyOptions.jsp
+++ b/ui/src/main/resources/jcr_root/libs/sling-cms/components/caconfig/scripts/policyOptions.jsp
@@ -19,7 +19,9 @@
  <%@include file="/libs/sling-cms/global.jsp"%>
 <option value="">Select Policy</option>
 <sling:getParent var="parent" resource="${slingRequest.requestPathInfo.suffixResource}" level="2" />
+${parent.path}
 <c:set var="query" value="SELECT * FROM [nt:unstructured] WHERE [sling:resourceType] = 'sling-cms/components/caconfig/policy' AND ISDESCENDANTNODE([${parent.path}]) ORDER BY [jcr:title]" />
+${query}
 <c:forEach var="policy" items="${sling:findResources(resourceResolver,query,'JCR-SQL2')}">
     <option value="${policy.path}" ${policy.path == editProperties.policyPath ? 'selected' : ''}><sling:encode value="${policy.valueMap['jcr:title']}" mode="HTML" /></option>
 </c:forEach>
\ No newline at end of file