Tuesday 12 April 2016

How to get Service Resource Resolver ?

Goal:

How to get Service Resource resolver ?

Explanation:

One of the Important change in AEM 6.1 securities is related to Admin Resourceresolver. In AEM 6.1 getAdministrativeResourceResolver has been deprecated other way to get this resourceresolver is using serviceResourceResolver.

Steps:

Go to /crx/explorer and click on “User Administration” link. On the popup, click on “Create System User” button, and enter the userid (anything you like).


Goto Useradmin console and provide required permissions for the user.

After creating the user and assigning appropriate permission, you need to add an entry in the “Apache Sling Service User Mapper Service”. This entry is to allow your bundle to access the permissions of the system user.

Go to Configuration Manager in the system console and search for “User Mapper Service”

<bundle symbolic name>:<any name of service>=<system user id>

*You need to add all the bundles that access the permissions of the system user. It can also be the bundle shipped with AEM.

If you see an error in the error log, which cannot access service for the specified package or bundle, it means you need to an entry for that bundle here.


Get the Service Resource Resolver in code

Map<String, Object> param = new HashMap<String, Object>();

// writeService is the service name you gave in the configuration of user mapper service

param.put(ResourceResolverFactory.SUBSERVICE, “writeService”);

ResourceResolver resolver = resolverFactory.getServiceResourceResolver(param);


Now this resourceresolver is used as per the permissions given for the user.

Saturday 9 April 2016

QR Code Generator component


Goal:

To Develop a component for generating QR code in AEM.

How To ??

Create a AEM component with the below structure.


Jsp:

<img width="<%=properties.get(WIDTH,"")%>" src="<%= request.getContextPath() %>/libs/wcm/mobile/qrcode.png?url=<%=properties.get(CODE,"")%>"/>

Mobile QR Code Generatorcom.day.cq.wcm.cq-wcm-mobile-qrcode will be used to generate the QR code.
/libs/wcm/mobile/qrcode.png


First Touch UI Component


Goal :

To create our first Touch UI component.

Steps:

  1. Create a component name touchui.
  2. Create a node with primary type nt:unstructured name cq:dialog.
    1. Property sling:resourceType and value cq/gui/components/authoring/dialog.
  3. Create a node with primary type nt:unstructured name content under cq:dialog node.
    1. Property sling:resourceType and value granite/ui/components/foundation/container.
  4. Create a node with primary type nt:unstructured name layout under content node.
    1. Property sling:resourceType and value granite/ui/components/foundation/layouts/tabs.
    2. Property type value as nav.
  5. Create a node with primary type nt:unstructured name items under content node.
  6. Create a node with primary type nt:unstructured name section under items node.
    1. Property sling:resourceType and value granite/ui/components/foundation/section.
  7. Create a node with primary type nt:unstructured name layout under section node.
    1. Property sling:resourceType and value granite/ui/components/foundation/layouts/fixedcolumns.
  8. Create a node with primary type nt:unstructured name items under section node.
  9. Create a node with primary type nt:unstructured name column under items node.
    1. Property sling:resourceType and value granite/ui/components/foundation/container
  10. Create a node with primary type nt:unstructured name items under column node.
  11. Create a node with primary type nt:unstructured name textfield under items node.
    1. Property fieldLabel and value TextField
    2. Property name and value ./name.
    3. Property sling:resourceType and value granite/ui/components/foundation/form/textfield.

Note :

To develop all types of widgets in touch UI download below dialog implementation