Thursday 14 June 2018

RedirectTarget property is not working in AEM 6.2

I tried to redirect a page to another using redirectTarget page property in wcmmode=disabled in author instance.

This redirectTarget property is working on Geomertrixx site and not on we-retail site.

Root Cause:
Geomertrixx site is created using template /libs/foundation/components/page and we-retail site is created using wcm/foundation/components/page.

Page component under foundation path is having code to redirect to another page, where as page component under wcm is not having code to redirect. In page.jsp we have code to redirect response.sendRedirect(redirectPath); which we don't have it in page.html.

Try these:
  • Try running AEM on publish runmode. 
  • Try creating a page with sling:resourceType: foundation/components/redirect. 

Saturday 9 June 2018

Access ClientLibs under apps folder through ClientLibraryProxyServlet

AEM provides ClientLibs feature to organize JS and CSS. Clientlibs can be created as 

  1. Approach 1: Place all files under /etc/designs/{project}/clientlibs path.
  2. Approach 2: Creating clientlibs under each component. Disadvantage with this approach is it increases number of calls to load clientlibs throuhout the page. This doesn't follow best practices as CSS will not be loaded in head section.
  3. Approach 3: Place clientlibs under /apps/project/. 
/apps folder is restricted to access by dispatcher. So we need to enable ClientLibraryProxyServlet  to access the clientlibs from apps folder.  Below are the steps to enable clientLibrary Proxy.

  • Create a new client library under /apps/... with new category. Let's say myapp.all
  • Add a embed property and  include all modular component library. (firstcomp,secondcomp)
  • Add boolean allowProxy = 'true'
  • On the headlibs.jsp include the above 
  • Then the clientlib will then be proxied via  there by passing access control set on the clientlib.

    • Configure dispatcher.any to allow for /etc.clientlibs/