Submitting Mobile Data to Adobe CQ using a Sling Post Servlet

-Scott MacDonald

You can create an Adobe CQ mobile form using JQuery Mobile API and submit the data to Adobe CQ using a Sling Post Servlet. When a mobile user fills in the form and clicks the submit button, form data is submitted to Adobe CQ.



Read the full blog post at Adobe Digital Marketing Blog

CQ coding patterns: Sling vs JCR (part 2)

- Jörg Hoh

In the last posting I showed the benefits of Sling regarding resource access over plain JCR. But not only in resource access both frameworks offer similar functionality, but also in the important area of listening to changes in the repository. So today I want to compare JCR observation to Sling eventing.

JCR observation is a part of the JCR specification and is a very easy way to listen for changes in the repository.

@component (immediate=true, metatype=false)
class Listener implements ObservationListener {

  SlingRepository repo;

  Session session;
  Logger log = LoggerFactory.getLogger (Listener.class);

  protected void activate () {
    try {
      Session adminSession = repo.loginAdministrative(null);
      session = adminSession.impersonate (new SimpleCredentials("author",new char[0]));
      adminSession = null;
      session.getObservationManager.addEventListener( this, // listener
        "/", // absPath
        true, // isDeep
        null, // uuid
        null, //nodeTypeNames
        true // noLocal
    } catch (RepositoryException e) {
      log.error ("Error while registering observation", e);

  protected void deactivate() {
    session = null:

  private handleEvents (Events events) {
    while (events.hasNext()) {
      Event e =;
      … // do here your event handling

In JCR the creation of an observation listener is straight forward, also the event listening. The observation process is tied to the lifetime of the session, which is started and stopped at activation/deactivation of this sling service. This kind of implementation is a common pattern.



Read the complete blog post at


CQ5 coding patterns: Sling vs JCR (part 1)

- Jörg Hoh

CQ5 as a complex framework is built on top of various other frameworks, on the server-side the most notably ones are JCR (with its implementation Apache Jackrabbit) and Apache Sling. Both are very powerful frameworks, but both of them have some overlap in functionality:

In these 2 areas you can work with both frameworks, and achieve good results with both. So, the question is, in what situation should you prefer Sling and in what situation pure JCR.

First, and I hope you agree here, in 99% of all cases use the an abstracted framework is recommended over the use of concrete technology (everybody uses JDBC and noone a direct database interface for e.g. MySQL) . It usually offers more flexibility and an easier learning cure. Same here. While on pure JCR you only work with raw repository structures (nodes and properties), the Sling resource abstraction offers you easier handling (no need to deal with the repository exceptions any more) and much more options to interact with you business objects and services.



Read the complete blog post at