Thursday, 23 June 2016

Creating an AEM Sightly component that uses JavaScript

You can create an Adobe Experience Manager (AEM) Sightly component that uses JavaScript. By using JavaScript as part of your Sightly component, you can create a more dynamic component that responds to events such as when the user scrolls over text with the mouse. For example, you can change the background color an AEM web page, as shown in the following illustration. 
An AEM Sightly component that uses JavaScript

Use Sling Model with Sightly in AEM

Sling Models
Many Sling projects want to be able to create model objects – POJOs which are automatically mapped from Sling objects, typically resources, but also request objects. Sometimes these POJOs need OSGi services as well.

In simple terms Sling Models are simple POJO classes which are mapped automatically with Sling Objects (resource, request objects..) and allow us to access jcr node property values directly into java classes.


Advantages of using Sling Models
  • Pure POJO classes.
  • Entirely annotation driven(Need to write less code).
  • Can adapt multiple objects –  – minimal required Resource and SlingHttpServletRequest OOTB, support resource properties (via ValueMap), SlingBindings, OSGi services, request attributes
  • Support both classes and interfaces.
  • Plugabble.
  •  Work with existing Sling infrastructure (i.e. not require changes to other bundles).


Developing a custom Adobe Experience Manager Quiz Component

You can develop a custom Adobe Experience Manager Quiz component that lets your web site visitors perform an on-line quiz and view the results. There are business requirements that require web visitors to perform an online quiz and then track the results. Building an AEM custom quiz component satisfies this business requirement. 
Assume that another requirement for the quiz component is the questions and corresponding answers are configurable. That is, an AEM author can set them without updating the component's application logic.
Note:
Using AEM adaptive forms or other forms is not a recommended way to develop a custom AEM quiz component. Instead, its better to develop a custom component as discussed in this article.
The Quiz application is made up of two parts:
  • Quiz component -  allows web visitors to answer displayed questions and view the results
  • Quiz configuration - allows AEM authors to set questions and answers
The following illustration shows the logic flow for the Quiz component. 
The Quiz component logic flow

1. The AEM Quiz configuration component lets an author set data values used in the quiz component. 
2. The quiz configuration data is stored in the AEM JCR. 
3. An AEM Service reads the JCR data.
4. The OSGi Service converts the JCR data to JSON data. 
5. The Quiz component uses the JSON data to render the quiz. 

AEM 6.1 Downgrade of a Java version and quickstart shows UnsupportedClassVersionError major.minor version 52.0

Sometimes we get below error  when accessing any AEM pages.

Caused by: java.lang.UnsupportedClassVersionError: org/apache/jsp/apps/sling/servlet/errorhandler/_404_jsp : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method) 

Resoultion:
NOTE: Please backup your AEM instance before doing this
  • Go to localhost:4502/system/console/configMgr
  • If the page opens, login as "admin"
    • Go to Menu > OSGI > Bundles [http://localhost:4502/system/console/bundles]
    • Find this "Apache Sling Commons FileSystem ClassLoader (org.apache.sling.commons.fsclassloader)" and note the BundleID (it is 218 for me)
    • STOP AEM
    • On Windows Explorer go to this path where your AEM is installed.. $path\aem-61-author\crx-quickstart\launchpad\felix\bundle218\data
    • Delete the classes folder under it.
    • Restart AEM.. this should fix the issue.
  • If the page above does not open,
    • (assuming the bundle-id is 218)
    • STOP AEM
    • On Windows Explorer go to this path where your AEM is installed.. __ $path\aem-61-author\crx-quickstart\launchpad\felix\bundle218\data __
    • Delete the classes folder under it.
    • Restart AEM.. this should fix the issue.

Tuesday, 14 June 2016

Sonarcube PDF report generation - Code Review

  • Download Sonarcube 4.5.7 version.
  • Download the pdf repport plugin 1.4 version from. 
    • Copy and paste the pdf report plugin to ../extensions/plugins/
    •  Start the server by running ../bin/StartSonar.bat.


Wednesday, 1 June 2016

Bulk Editor in AEM

The Bulk Editor allows for very efficient editing when the visual page context is not needed as it lets you:
  • search for (and display) content from multiple pages; this is done using GQL (Google Query Language)
  • edit this content directly in the bulk editor
  • save the changes (to the originating pages)
  • export this content to a tab-separated (.tsv) spreadsheet file
file