Thursday, 1 August 2013

Creating AEM applications that use the Query Builder API to display search results

You can create an AEM application that searches the CQ repository for assets and displays the results to the end user. For example, you can search CQ pages under a specific repository node (for example, in a child node under /content) and look for a specific search term. All pages that satisfy the search criteria are included in the search results. To search the Adobe CQ repository, you use Query Builder API. This API requires that you define search parameters, and an optional filter. After you execute the query, the results are stored in a result set. You can display the result set in an Adobe CQ web page.

When working with the Query Builder API, you can use a Java API or a Restful API. This development article uses the Adobe CQ Query Builder Java API to perform searches.

A user specifies search criteria and the CQ repository is searched using the defined criteria 

You can search the AEM repository and display the data result set. For example, here is the data result set for CQ pages located under /content and using the search term: "Geometrixx".

 Results produced by using the Query Builder API

To read this development article, click: http://helpx.adobe.com/experience-manager/using/using-query-builder-api.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


Monday, 29 July 2013

Adobe Marketing Cloud Communities now open for business

Today is the start of a new era for the Adobe Digital Marketing Cloud and its community. After months of hard work, the day has arrived. That is correct -- the Adobe Marketing Cloud Communities are now open for business.

The Adobe Experience Manager forum - part of the Adobe Marketing Cloud Community

The Marketing Cloud community is built using Adobe's latest Social Community platform, part of Experience Manager. The communities make up one key aspect of the Marketing Cloud help, support and learning social strategy, which includes Adobe.com help, Twitter support and advice and is tied to the existing documentation and help experiences.  The Marketing Cloud community is the place for you to dig into the solutions you're using, including Analytics, Experience Manager, Social, Target and even our new Marketing Cloud.

How to get involved with the Adobe Marketing Cloud community
1. Go to the following URL: http://help-forums.adobe.com/content/adobeforums/en.html.
2. Sign in with your Adobe ID.
3. Create your profile by clicking your profile name in the upper right hand corner.
4. Click on one of the Adobe Digital Marketing solutions that you are interested in.
5. Post a new question (or discussion) or help other community members by answering existing questions.

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, 25 July 2013

Uploading files to Adobe Experience Manager DAM using AssetManager API

You can create an Adobe Experience Manager (AEM) application that lets a user select a file from their local desktop and upload it to AEM Digital Asset Manager (DAM). The file is posted to a custom Sling Servlet that persists an image file in the AEM DAM.



An Adobe AEM client web page that lets a user select a file and upload it to AEM

In this example, notice that a file named lake.jpg is selected. Once the file is uploaded, the Sling Servlet persists the file in the AEM DAM, as shown in the following illustration.


A file is located in the Adobe CQ DAM that was uploaded using a Sling Servlet


When you use the AssetManager API to persist a file in the AEM DAM, AEM automatically creates different renditions for the asset, as shown in this illustration.



Java code that works in non-sling Java servlets to upload a file throws an exception within Adobe CQ. That is, using Apache Commons FileUpload application logic (that works in non-sling Java servlets used in other projects) throws this exception:

java.lang.IllegalStateException: Request Data has already been read

Here is an example of Apache Commons FileUpload Java code that works in other projects - but not in Adobe CQ:

 String fileName = "";
         org.apache.commons.fileupload.FileItem fileItem;
         fileName = "";
         fileItem = null;
         Iterator iterator;

         try {
                 
             List items = (new org.apache.commons.fileupload.servlet.ServletFileUpload(new org.apache.commons.fileupload.disk.DiskFileItemFactory())).parseRequest(request);
             iterator = items.iterator();
             while(iterator.hasNext())
             {
                 Object itemObj = iterator.next();
                 org.apache.commons.fileupload.FileItem item = (org.apache.commons.fileupload.FileItem)itemObj;
                 if(item.getFieldName().equals("our-file"))
                 {
                     fileItem = item;
                     fileName = item.getName();

...

At first, I did not realize why code that I have used in other projects would not work in Adobe CQ.  As I researched this issue further, I discovered that Sling reads the file content automatically, so the code attempts to read in the request data twice. 

This explains the exception. Now the question is how do you successfully get the file when using a Sling servlet? The answer is you can read the file using Sling APIs.  The following Java code example represents the doPost method of a sling servlet that reads the file that is uploaded. The fully qualified names of the Java objects are used so you understand the data types used in this code fragment.

 @Override
     protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServerException, IOException {
       
       
    try
    {
    final boolean isMultipart = org.apache.commons.fileupload.servlet.ServletFileUpload.isMultipartContent(request);
    PrintWriter out = null;
     
      out = response.getWriter();
      if (isMultipart) {
        final java.util.Map<String, org.apache.sling.api.request.RequestParameter[]> params = request.getRequestParameterMap();
        for (final java.util.Map.Entry<String, org.apache.sling.api.request.RequestParameter[]> pairs : params.entrySet()) {
          final String k = pairs.getKey();
          final org.apache.sling.api.request.RequestParameter[] pArr = pairs.getValue();
          final org.apache.sling.api.request.RequestParameter param = pArr[0];
          final InputStream stream = param.getInputStream();
          if (param.isFormField()) {
            out.println("Form field " + k + " with value " + org.apache.commons.fileupload.util.Streams.asString(stream) + " detected.");
          } else {
            out.println("File field " + k + " with file name " + param.getFileName() + " detected.");
          }
        }
      }
    }
     
         catch (Exception e) {
             e.printStackTrace();
         }
      
     }

To read this development article, click:

http://helpx.adobe.com/experience-manager/using/uploading-files-aem1.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, 9 July 2013

Using AJAX requests to display Adobe CQ users in a grid control

You can use an AJAX request to retrieve Adobe CQ users and display the result set in a data grid control. To retrieve user data from Adobe CQ, you use a com.day.cq.security.UserManager instance that belongs to the Adobe CQ API. This API provides access to both Adobe CQ users and groups. The following illustration shows Adobe CQ users displayed within a grid control.
Adobe CQ users 
This development article guides you through creating this AEM application that retrieves CQ user data and displays the data in a client web page. To view this development article, click:

http://helpx.adobe.com/experience-manager/using/using-ajax-requests-display-cq.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


Wednesday, 26 June 2013

Launch the new Digital Marketing Support Community

We are getting ready to launch the new Digital Marketing support community in mid-July 2013 (only a few weeks away). The new community will feature new CQ-based forums and new Digital Marketing help pages that contain resources such as a 'Spot Light' section, articles, videos, FAQs, Twitter feeds, and so on.  The new forums will be monitored by a growing pool of Digital Marketing experts ready to help you out and answer your questions.

Likewise, if you are an Adobe CQ or other Digital Marketing software user and would like to help other Digital Marketing customers, we encourage you to join our community. As we draw closer to the launch date, additional details will be posted.

The next AEM 'How To' article will be posted to this Blog later in July after we launch the new support community.

The new community is live - for details, see: http://scottsdigitalcommunity.blogspot.ca/2013/07/adobe-marketing-cloud-communities-now.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


Monday, 10 June 2013

Submitting Adobe Experience Manager form data to custom Sling Servlets

You can create an Adobe Experience Manager application that lets a user enter data into a web page and post data to a custom Sling Servlet. The posted data is processed by a custom Sling Servlet. In this development article, the Sling Servlet is created by using Maven.

An end user filling in a CQ form and posting the data to a Sling Servlet

The Sling Servlet that is created encodes the submitted form data into JSON formatted data and returns the data to the web client where it is displayed.

A web application displaying JSON formatted data returned by a Sling Servlet

A custom Sling Servlet is an OSGi bundle. However, a difference between an OSGi bundle that contains a service and an OSGi bundle that contains a Sling Servlet is the former requires that you create an instance of the service. For example, assume that an OSGi bundle contains a service based on a Java class named com.adobe.cq.CustomerService. To get data from the client web page to this OSGi service, you have to create an instance of com.adobe.cq.CustomerService, as shown in this example.

com.adobe.cq.CustomerService cs = sling.getService(com.adobe.cq.CustomerService.class);

Then you invoke a service method, as shown in this example that invokes the injestCustData method.

cs.injestCustData(first, last, phone, desc) ;

For information about how to create an Adobe CQ application that builds an OSGi bundle that contains a service (not a Sling Servlet), see Querying Adobe Experience Manager Data using the JCR API.

In contrast, when working with an OSGi bundle that contains a Sling Servlet, you post data to the Sling Servlet's doPost method. That is, you can use a JQuery AJAX request to post data to the Sling Servlet, as shown in the following example.

//Use JQuery AJAX request to post data to a Sling Servlet
 $.ajax({
         type: 'POST',    
         url:'/bin/mySearchServlet',
         data:'id='+ claimId+'&firstName='+ myFirst+'&lastName='+ myLast+'&address='+ address+'&cat='+ cat+'&state='+ state+'&details='+ details+'&date='+ date+'&city='+ city,
         success: function(msg){
           alert(msg); //display the data returned by the servlet
         }
     });

This article discusses how to use Maven to develop the Sling Servlet, how to deploy it, and then how to post data to it from a client web page.

To read this development article, click:

http://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html

To watch the video, click:



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, 4 June 2013

Submitting .NET client application data to the Adobe CQ JCR

You can create a .NET client application that can modify Adobe CQ JCR nodes and properties by using a Restful Sling request. The .NET application can create a node, modify an existing node, and delete a node. For example, assume that you responsible for building an application for an insurance company interested in persisting claim data in the Adobe CQ JCR. When an end user fills in the form and clicks the submit button, the .NET application data is submitted to Adobe CQ. A new node is created and the data is stored as node properties.

A .NET client application that is able to submit data to the Adobe CQ JCR

When the user fills in this .NET application and clicks the 'Submit Claim to JCR', the data is submitted to the CQ JCR.

















Claim data submitted from the .NET client application

Because Adobe CQ accepts Restful requests, you are not limited to the type of client technology to use to submit data. That is, you can use any client technology that supports Restful requests. This development article walks you through how to build this .NET client application that can submit data to the Adobe CQ JCR. To read this entire development article, click

http://helpx.adobe.com/experience-manager/using/using-net-client-application.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