Friday 18 December 2015

Winners of the 2015 AEM Community Code Contest

During the month of November 2015, the AEM community team held a code contest where AEM Developers submitted functioning AEM code. All of these submissions will be discussed in upcoming 2016 AEM Community articles.

The AEM community team presents you with the three winning submissions:

AEM Quiz Component

The AEM Quiz component lets AEM authors configure a quiz by setting questions and answers. Question and Answer and other details of the quiz is authored using the Quiz Configuration component.  The Quiz component refers to the par/quiz_config node of a page. The result is a component that you can use in an AEM site that lets visitors fill out a quiz.



Congratulations to Praveen Dubey for submitting this first place submission. One of the reasons why this was selected as first place is it has addressed many questions in the AEM Forums on how to write a quiz component.

Vanity URL Manager

The vanity URL manager is a way for AEM users to manage vanity URLs. This tool is a new view in the Touch UI. Using this tool, you can filter by site and peform other operations such as deleting them. 




Congratulations to Lokesh BS for submitting this code.


Custom Carousel Component

The  custom carousel component uses panels and grids where author can see what image they are selecting and which image or items need to update. This submission is a great example of how you can customize out of the box AEM functionality to meet your business requirements. 


Congratulations to Ganesh Malaiyappan for submitting this entry. 


Join the Adobe Experience Cloud Community 

Join the Adobe Experience Cloud Community by clicking this banner




I (Scott Macdonald) am a Senior Digital Marketing Community Manager at Adobe Systems with 20 years in the high tech industry. I am also a programmer with knowledge in Java, JavaScript, C#,C++, HTML, XML and ActionScript. If  you would like to see more CQ or other Adobe Digital Marketing end to end articles like this, then leave a comment and let me know what content you would like to see.


TwitterFollow the Digital Marketing Customer Care team on Twitter @AdobeExpCare.

YouTube: Subscribe to the AEM Community Channel



 

Monday 14 December 2015

Example JCR SQL Queries


Search for JCR retPlugin nodes in JCR

The following code example shows JCR SQL2 syntax to search for all rtePlugin nodes under /apps.

import javax.jcr.Repository;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;
import javax.jcr.Node;
import javax.jcr.query.Query;

import org.apache.jackrabbit.commons.JcrUtils;

public class TestJCR {


    public static void main(String [] args)
    {


        try {

            String aemUrl = "http://localhost:4502/crx/server" ;
            //Create a connection to the CQ repository running on local host
            Repository repository = JcrUtils.getRepository(aemUrl);



            //Create a Session
            javax.jcr.Session session = repository.login( new SimpleCredentials("admin", "admin".toCharArray()));

            //Obtain the query manager for the session ...
            javax.jcr.query.QueryManager queryManager = session.getWorkspace().getQueryManager();

            //Specify the AEM JCR path where examples users are stored at /home/users/test

            String sqlStatement = "select * from [nt:unstructured] as p where isdescendantnode (p, [/apps]) AND NAME(p)='rtePlugins'";


            javax.jcr.query.Query query = queryManager.createQuery(sqlStatement,"JCR-SQL2");

            //Execute the query and get the results ...
            javax.jcr.query.QueryResult result = query.execute();

            //Iterate over the nodes in the results ...
            javax.jcr.NodeIterator nodeIter = result.getNodes();

            long mySize = nodeIter.getSize();

            while ( nodeIter.hasNext() ) {

                //For each node-- get the path of the node
                javax.jcr.Node node = nodeIter.nextNode();

                String myPath = node.getPath();

                System.out.println(myPath);
            }

            // Save the session changes and log out
            session.save();
            session.logout();


        }
        catch(Exception e){
            e.printStackTrace();
        }

    }



}

Using Date Values in JCR SQL2 Queries

While developing AEM tools for my team, I am using some date-based queries while performing JCR-SQL2 queries. While this will not be a community article, I will still post the date-based queries so people new to JCR SQL2 can reference this. Futhermore - the dates are variables used in the query string.

This example is based on this stackoverflow thread: http://stackoverflow.com/questions/15117075/jcr-sql2-query-comparing-dates.

The important thing to consider and is shown below is:

The best way to use dates in a query is to use CAST to force the conversion of a string representation of a date/time into a DATE value used by JCR.

 String sqlStatement2 = "select * from [rep:User] where isdescendantnode('/home/users/mypath') and [jcr:created] > cast('"+ year +"-"+monthStr+"-"+dayStr+"T00:00:00.000+02:00' as date) and [jcr:created] < cast('"+ year2 +"-"+monthStr2+"-"+dayStr2+"T23:59:59.000+02:00' as date)";

  javax.jcr.query.Query query = queryManager.createQuery(sqlStatement2,"JCR-SQL2");

  //Execute the query and get the results ...
   javax.jcr.query.QueryResult result = query.execute();

   //Iterate over the nodes in the results ...
   javax.jcr.NodeIterator nodeIter = result.getNodes();
   while ( nodeIter.hasNext() ) {


                //For each node-- get the path of the node
                javax.jcr.Node node = nodeIter.nextNode();

                String myPath = node.getPath();
                //do something with path value.... 


}

Join the Adobe Experience Cloud Community 

Join the Adobe Experience Cloud Community by clicking this banner




I (Scott Macdonald) am a Senior Digital Marketing Community Manager at Adobe Systems with 20 years in the high tech industry. I am also a programmer with knowledge in Java, JavaScript, C#,C++, HTML, XML and ActionScript. If  you would like to see more CQ or other Adobe Digital Marketing end to end articles like this, then leave a comment and let me know what content you would like to see.


TwitterFollow the Digital Marketing Customer Care team on Twitter @AdobeExpCare.

YouTube: Subscribe to the AEM Community Channel

Saturday 5 December 2015

Congratulations to Lokesh for 2015 AEM Community member of the Year

Congratulations to Lokesh BS - he was the AEM 2015 community member of the year. He has helped many community members throughout this year by submitting many AEM code packages, helping in the forums (currently 3rd place on leaderboard), doing ASK the Experts.

In recognition of his great community work - I will be travelling to New York this week to award Lo Ki with a brand new IPAD, an AEM 2015 Community member plaque, and a dinner at a New York Restaurant on Adobe.




I also want to say congratulations ot Praveen Dubey - who was 2nd  AEM community member of the year and started helping the AEM Community in May 2015 and has been very strong since.
Its awesome members like Praveen and Lokesh that help AEM developers become successful in their AEM projects. Great Job to both of you!!


Join the Adobe Experience Cloud Community 

Join the Adobe Experience Cloud Community by clicking this banner




I (Scott Macdonald) am a Senior Digital Marketing Community Manager at Adobe Systems with 20 years in the high tech industry. I am also a programmer with knowledge in Java, JavaScript, C#,C++, HTML, XML and ActionScript. If  you would like to see more CQ or other Adobe Digital Marketing end to end articles like this, then leave a comment and let me know what content you would like to see.


TwitterFollow the Digital Marketing Customer Care team on Twitter @AdobeExpCare.

YouTube: Subscribe to the AEM Community Channel

Tuesday 1 December 2015

AEM Community Code Contest is now closed

Thanks AEM community for your great response to the code contest. We will be reviewing all entries and announce the winners by Dec 18, 2015. The three winning submissions will also be converted into community articles so our AEM community can benefit from these entries and learn new AEM skills.

These community articles will be posted in the first couple of months in 2016.



Join the Adobe Experience Cloud Community 

Join the Adobe Experience Cloud Community by clicking this banner




I (Scott Macdonald) am a Senior Digital Marketing Community Manager at Adobe Systems with 20 years in the high tech industry. I am also a programmer with knowledge in Java, JavaScript, C#,C++, HTML, XML and ActionScript. If  you would like to see more CQ or other Adobe Digital Marketing end to end articles like this, then leave a comment and let me know what content you would like to see.


TwitterFollow the Digital Marketing Customer Care team on Twitter @AdobeExpCare.

YouTube: Subscribe to the AEM Community Channel

Tuesday 24 November 2015

Getting Started with Adobe Experience Manager 6.1 Apps

You can create a mobile application using a mobile JavaScript framework, such  as the ionic framework, and then import the mobile application into Adobe Experience Manager (AEM) 6.1. For information, see Ionic Framework.

Import the mobile application by dragging and dropping the mobile app from your file system into AEM, as shown in the following illustration.




Once imported into AEM, the mobile application becomes an AEM application and can use AEM functionality, such as the AEM DAM and AEM authoring capabilities. This development article walks you through how to build a basic Ionic mobile application, import it into AEM, and then configure it so it becomes an AEM application that can be authored, like other AEM content.

To read this development article, click   https://helpx.adobe.com/experience-manager/using/aem61_apps.html.

Join the Adobe Experience Cloud Community 

Join the Adobe Experience Cloud Community by clicking this banner




I (Scott Macdonald) am a Senior Digital Marketing Community Manager at Adobe Systems with 20 years in the high tech industry. I am also a programmer with knowledge in Java, JavaScript, C#,C++, HTML, XML and ActionScript. If  you would like to see more CQ or other Adobe Digital Marketing end to end articles like this, then leave a comment and let me know what content you would like to see.


TwitterFollow the Digital Marketing Customer Care team on Twitter @AdobeExpCare.

YouTube: Subscribe to the AEM Community Channel

Tuesday 17 November 2015

Creating an AEM HTL Component that uses the QueryBuilder API

You can create an Adobe Experience Manager (AEM)  HTL (formally Sightly)  component that can be used within the AEM Touch UI view. Furthermore, you can use HTL and the QueryBuilder API to develop the AEM component that displays AEM JCR data.

HTL  is an AEM  template language that can be used to replace the use of JSP when developing an AEM component. HTL helps you to separate your design from your application logic.  In this use case, the HTL logic is located within an HTML file and displays the result set. The Java part of the HTL component uses the QueryBuilder API.




Join the Adobe Experience Cloud Community 

Join the Adobe Experience Cloud Community by clicking this banner




I (Scott Macdonald) am a Senior Digital Marketing Community Manager at Adobe Systems with 20 years in the high tech industry. I am also a programmer with knowledge in Java, JavaScript, C#,C++, HTML, XML and ActionScript. If  you would like to see more CQ or other Adobe Digital Marketing end to end articles like this, then leave a comment and let me know what content you would like to see.


TwitterFollow the Digital Marketing Customer Care team on Twitter @AdobeExpCare.

YouTube: Subscribe to the AEM Community Channel

Thursday 5 November 2015

Creating an AEM System User for AEM 6.1

In AEM 6.1, you must create an AEM System User to successfully get a session using code such as:

Map<String, Object> param = new HashMap<String, Object>();
param.put(ResourceResolverFactory.SUBSERVICE, "datawrite");
ResourceResolver resolver = null;

try {
           
    //Invoke the adaptTo method to create a Session used to create a QueryManager
 resolver = resolverFactory.getServiceResourceResolver(param);
    session = resolver.adaptTo(Session.class);

Note - see this article:

Querying Adobe Experience Manager 6 data using the Sling getServiceResourceResolver method

This code will not work in AEM 6.1 using a standard user, 

Note: All AEM 6.x HelpX  Articles will be updated soon to use a System user to obtain a Session object from within an OSGi bundle.

To create a system user, perform these tasks:


  1. Open http://localhost:4502/crx/explorer/index.jsp
  2. Login as admin
  3. Click User Administration
  4. Click Create System User
  5. Set the UserId
  6. Click Save

Once created, you can extend permissions like a normal user using the AEM ACL functionality. 

Join the Adobe Experience Cloud Community 

Join the Adobe Experience Cloud Community by clicking this banner




I (Scott Macdonald) am a Senior Digital Marketing Community Manager at Adobe Systems with 20 years in the high tech industry. I am also a programmer with knowledge in Java, JavaScript, C#,C++, HTML, XML and ActionScript. If  you would like to see more CQ or other Adobe Digital Marketing end to end articles like this, then leave a comment and let me know what content you would like to see.


TwitterFollow the Digital Marketing Customer Care team on Twitter @AdobeExpCare.

YouTube: Subscribe to the AEM Community Channel



Monday 2 November 2015

Using the Java Query Object Model within Adobe Experience Manager

You can create an AEM application that searches the CQ repository for JCR data and displays results to the end user. For example, you can search CQ pages under a specific repository node (for example, nodes under /content) and look for a specific search term. All content that satisfy the search criteria are included in the search results. To search the Adobe CQ repository, you use the JCR Query Object Model (JQOM) API. For information about the API, see Interface QueryObjectModel.

JQOM is an AEM query language that is like ‘prepared statements’ and SQL2 is like ‘statements’ in JDBC queries.  For example, a use case may require to retrieve all JCR nodes from ‘Geometrixx’ which has the property pageTitle.

QueryObjectModelFactory qf = currentNode.getSession().getWorkspace().getQueryManager().getQOMFactory();
Selector selector = qf.selector("cq:PageContent", "s"); 
Constraint constriant = qf.descendantNode("s", "/content/geometrixx");
constriant = qf.and(constriant, qf.propertyExistence("s", "pageTitle"));
QueryObjectModel qm = qf.createQuery(selector, constriant, null, null);

QueryObjectModelFactory gets the instance of the JCR Object Model.  The Selector is used to set the type of node that the query needs to look at. Constraint is used to add all the constraints which is like where condition into the query model. Finally a query is created with the selector and constraint that captures the response as a QueryObjectModel.




To read this development article, click https://helpx.adobe.com/experience-manager/using/jqom.html.

Join the Adobe Experience Cloud Community 

Join the Adobe Experience Cloud Community by clicking this banner




I (Scott Macdonald) am a Senior Digital Marketing Community Manager at Adobe Systems with 20 years in the high tech industry. I am also a programmer with knowledge in Java, JavaScript, C#,C++, HTML, XML and ActionScript. If  you would like to see more CQ or other Adobe Digital Marketing end to end articles like this, then leave a comment and let me know what content you would like to see.


TwitterFollow the Digital Marketing Customer Care team on Twitter @AdobeExpCare.

YouTube: Subscribe to the AEM Community Channel

Thursday 29 October 2015

Reading AEM OSGi Configuration Values

You can define OSGi configuration values by using CRXDE lite and dynamically read these values from within an OSGi service. By defining configuration values, you can define values used by an OSGi service and use these values while the service is running. Unlike hard-coding values in an AEM OSGi service, defining values in CRXDE lite lets you modify configuration values without re-compiling and re-deploying the OSGi bundle.



As shown in the previous illustration, you can define OSGi configuration values in CRXDE lite. To define configuration values, you define a node of type sling:OsgiConfig. Then you define properties which are the configuration values.




This development article guides you through creating an OSGi bundle that reads OSGi configuration values that are defined in CRXDE Lite.

AEM 6.1/2


To read this development article, click:

https://helpx.adobe.com/experience-manager/using/osgi_config.html.

AEM 6.3

To read AEM 6.3 version, see
 https://helpx.adobe.com/experience-manager/using/osgi_config63.html



Adobe Digital Marketing Community

Join the Adobe Digital Marketing Community. Start by clicking this banner



I (Scott Macdonald) am a Senior Digital Marketing Community Manager at Adobe Systems with over 18 years in the high tech industry. I am also a programmer with knowledge in Java, JavaScript, C#,C++, HTML, XML and ActionScript. If  you would like to see more CQ or other Adobe Digital Marketing end to end articles like this, then leave a comment and let me know what content you would like to see.

TwitterFollow the Digital Marketing Customer Care team on Twitter @AdobeMktgCare.