3 Replies Latest reply on Feb 2, 2016 5:24 PM by liviu.chis19

    Sling resolver differences in OSGi vs JEE Adaptive Forms


      I recently tried migrating an adaptive form from an OSGI AEM Forms instance on a Mac (I know it's for dev only but I would hope this works) to a JEE instance via the package manager and received some errors.

      It seemed as though the OSGi instance sets its sling:resourceType properties using relative paths, which would make sense coming from a Sites background. So when I look at the structure in crx/de, I see

      <path_to_form>/jcr:content/guideContainer/layout -> sling:resourceType=fd/af/layouts/defaultGuideLayout which is a relative path

      When importing to JEE, this gives me the following error: javax.servlet.jsp.JspException: Could not find script fd/af/layouts/defaultGuideLayout/defaultGuideLayout.jsp

      If I then go into crx/de and manually change that to an absolute path - <path_to_form>/jcr:content/guideContainer/layout -> sling:resourceType=/libs/fd/af/layouts/defaultGuideLayout, the problem goes away. This is strange because all other components have relative sling:resourceTypes and have no problem.

      Even stranger is the error I got when I assigned the "Caption and Error on Top of Widget inside the Field box" in the Configure Field Layout dropdown of the Styling tab on a field in the form. Again, this gave an error when moving the package to JEE due to relative paths. Setting that value in OSGi set the following property:

      <path_to_field_node> -> fieldLayout=fd/af/layouts/field/afCaptionErrorOnTop

      Again, on JEE, that gave the error: javax.servlet.jsp.JspException: Could not find script fd/af/layouts/field/afCaptionErrorOnTop


      I then tried setting that value directly on my JEE server to see what it would be set to. Sure enough, it's an absolute path again - /libs/fd/af/layouts/field/afCaptionErrorOnTop/afCaptionErrorOnTop.jsp. Notice this time however, that it points right to the script, not to the component.

      Digging around in the forms components in crx/de, I found the json request that populates the aforementioned dropdown, can be seen at /libs/fd/af/components/guidefield/dialog/items/styling/items/fieldLayout

      Running that script in the browser on OSGi revealed, as you would expect, a json object with value of fd/af/layouts/field/afCaptionErrorOnTop, the relative path that it wrote in crx/de, whereas running that same script in JEE returned a json object with the absolute path to the script. So it seems like AEM knows in which cases a relative vs an absolute script is required, but seeing as it's seems to be environment specific, it makes migration very difficult.