Sling Pipes – A Rockstar Way to Deal with JCR

Posted on Monday, May 1, 2017 By

Today’s post is by guest writer Rima Mittal, who was invited to compete for the title of AEM Rockstar at the 2017 Adobe Summit. Along with the other finalists, we invited Rima to contribute a blog and video to our series, Rockstar Tips & Tricks. At the AEM Rockstar Session, Rima spoke on Sling Pipes – A Rockstar Way to deal with JCR. 

Rima Mittal is an Adobe Certified Lead AEM Developer and Consultant. She has extensive experience working on Java and AEM and has done multiple POCs on integrating AEM with external third-party systems. A strong believer in the importance of communities and knowledge sharing in the world of software development, she has been a speaker at various developer conferences like AEMHub 2015 and adaptTo() 2016. 

Ever encountered a situation where code changes were introduced after the client started authoring and some pages had to be re-authored? Ever spent time writing code just to modify a few hundred pages that were already authored, or with removing a component from hundreds of authored pages? Have you struggled to modify content already in the repository? Need a script to change existing production content? Sling Pipes to the rescue.

Sling Pipes

Sling Pipes is a tool for doing extract – transform – load operations through a resource tree configuration. This tiny toolset provides the ability to do such transformations with proven and reusable blocks, called pipes, streaming resources from one to the other.

A pipe is a JCR node with:

  • sling:resourceType property – Must be a pipe type registered by the plumber
  • name property – Used in bindings as an id
  • path property – Defines pipe’s input
  • expr property – Expression through which the pipe will execute
  • additionalBinding node – Node you can add to set “global” bindings (property=value) in pipe execution
  • additionalScripts – Multivalue property to declare scripts that can be reused in expressions
  • conf child node – Contains addition configuration of the pipe

Registered Pipes

 

 

Sling Pipes Demo

Here is a demo video with more on how to use and execute sling pipes in AEM.

 

More details can be found in the official documentation at https://sling.apache.org/documentation/bundles/sling-pipes.html

For any questions or comments, I can be reached on Twitter at @rimamittal or on LinkedIn at https://www.linkedin.com/in/rimamittal/

12:11 PM Permalink

AEM Multi-Site Tips & Tricks Preview – IMMERSE 2017

Posted on Monday, April 24, 2017 By

We are excited to share another post in the AEM Rockstar Tips & Tricks Guest Blog series! This Tips & Tricks preview is from Brett Birschbach, an AEM Certified Architect and AEM Rockstar semi-finalist who will be a session presenter at Adobe’s global virtual developer conference, IMMERSE May 15th – 19th 2017. Brett will detail his Tips & Tricks in a follow-up post after IMMERSE. Brett’s session will be on Tuesday, May 16, 1:15-2:15 PM Central (11:15-12:15 PDT).

Brett is the Adobe Marketing Cloud Solutions Architect for HS2 Solutions, a digital transformation company based in Chicago. He is a hands-on problem solver with experience leading large multinational, multi-site platform projects.  Brett led the development of the new Shared Component Properties feature in the open source ACS AEM Commons library. For more from Brett, visit his Github: HitmanInWis.

Multi-site platforms are the norm in a mature Adobe Experience Manager installation. However, most implementations, in true Agile fashion, start as a single site and then expand to support multiple. Suppose your client is the NFL and it wants to put all 32 teams on the same AEM platform. We all know that launching 32 team sites on day one is A Bad Idea, so likely you are going to start with just one site as a proof of concept.  However, Agile tends to tempt a lot of us in this situation into thinking that “I’ll just code for this one site now, and worry about multi-site support and code structures on the second site when I actually need them.”  YAGNI, right?  Except…you ARE going to need it.  Pretending you are building a single site when you know the platform is going to support multiple, thinking only in the present instead of taking a step back and getting the full picture, is a great way to paint yourself into a corner.

 

Man painted into corner

Image by Ali Moussa, HS2 Solutions

Coding a multi-site platform beginning with single-site patterns, we are faced with technical debt in making the transition to multi-site – technical debt that often never gets fully paid.  Let’s be real, clients want to see sites #2 through #32 launched as quickly as possible after site #1 is launched.  After all, that’s the vision you cast them – that they would easily be able to create and manage all their sites on a single platform using the same components and authoring techniques as the first site.  To the client, having a single working site seems like it should account for 80% of the total work, so the rest of the sites should be a snap.  You know as well as I do that the urgency to turn out these sites means that much of the technical debt accrued early in the project will be worked around and put off until resolution on a proverbial someday, never to be repaid.  Bad decisions made when creating the first site often linger on for as long as the platform lives.

Image by Ali Moussa, HS2 Solutions

But it doesn’t have to be this way.  Structuring your code base for multi-site success isn’t that hard to do, it’s just easier not to do it (which is why we end up in this situation).  But what if you had a step-by-step guide?  What if you could leverage the experience of peers who have already done it well?  This stuff isn’t rocket science, and the principles don’t change much from project to project.  No sense wasting your time trying to come up with all the techniques on your own.  Wouldn’t you rather be doing the fun stuff like banging out a sweet, interactive Schedule component for authors to drop onto those 32 NFL team sites?  Of course, you would!  That’s why I encourage you to attend the “Multi-Sites: Setting your Codebase Up for Success” session at Adobe IMMERSE 2017.

 

Why should you attend?

  • Adobe IMMERSE is the premier AEM developer conference of the year, focusing on the technical audience.  If you’re not already registered, sign up using the link above!
  • I’ll be covering Basic, Advanced, and Overachiever techniques, 15 in all, using the NFL example above (modified to HFL, to avoid any grumbling from the lawyers).
  • The techniques come from a successful, international, multi-site platform implementation hosting a dozen brand and corporate sites, so they are tried and proven.
  • Every example (yes, every last one) will be demonstrated by real code that you can download, look at, and play with in order to gain a true understanding that only code can give.

Disclaimer: Being a Green Bay native (and therefore huge Packers aficionado) I *may* take the liberty to take a few jabs at our archrivals in Chicago…don’t take it personally 🙂

 

 

 

2:53 PM Permalink

Be an #AEMRockstar: Use AEM DataLayer

Posted on Tuesday, April 18, 2017 By

Today’s guest post features the winner of our first AEM Rockstar Competition, Dan Klco of Perficient. Dan rocked Summit attendees with his presentation, so we asked him to share his DataLayer demo. In the coming weeks, we’ll share more AEM Rockstar posts and preview one semi-finalist’s IMMERSE presentation. Stay tuned!

Dan is an experienced Adobe Digital Marketing Technical Lead, Solution Architect, Consultant and Advisor. Through his career, he has become viewed as a valued thought leader in the industry, with solid skills in leading teams to implement successful digital marketing programs in the Adobe ecosystem. Dan is also a PMC Member of the Apache Sling project, which is the basis for Adobe’s Experience Manager product, this allows him unique insight into the AEM platform.

During the AEM Rockstar session at Adobe Summit, I had a chance to talk about Digital Marketing DataLayers in AEM. I discussed how this important design pattern can help simplify Adobe Experience Manager and Adobe Marketing Cloud integrations, and introduced AEM DataLayer, a new Open Source library for creating DataLayers in AEM.

I was thrilled to be awarded first prize for my presentation and would like to share some more with information with you about how to use the AEM DataLayer library on your project.

Step 1: Identifying Data to Track

In my talk, I discussed analyzing designs in the discovery phase, to identify what data you might need to capture for Digital Marketing. It is important to focus on the might rather than the need to ensure that your DataLayer will not require significant changes during the course of the implementation.

Given the page above, you may want to track some of the following information as an example:

 

Track Time

Scope

Information

Example

On Load

Page

Page URL

http://www.weretail.com/us/en/about-us.html

On Load

Page

Page Path

/us/en/about-us

On Load

Page

Site Section

about-us

On Load

Page

Region

us

On Load

Page

Language

en

On Load

Page

Page Title

About Us

On Load

Component

Video

/content/dam/we-retail/en/videos/Perficient-Digita-Agency-Reel.mp4

Event

Component

Video Play

Event

Component

Video Complete

Step 2: Configure AEM DataLayer

The AEM DataLayer is available as a downloadable AEM Package and is easy to install and incorporate into your project. Click here to watch my Spark video demo.

The steps to install and configure the AEM DataLayer are:

  1. Install the AEM DataLayer package
  2. Setup a Cloud Configuration for AEM DataLayer
  3. Add the Cloud Configuration on your site

Step 3: Add Your Custom DataLayer Code

To create your own DataLayer code, create a simple Bundle project and add the dependencies:

<dependency>

  <groupId>org.apache.sling</groupId>

  <artifactId>org.apache.sling.models.api</artifactId>

  <version>1.3.0</version>

  <scope>provided</scope>

</dependency>

<dependency>

  <groupId>com.perficient.aem</groupId>

  <artifactId>aem-datalayer.core</artifactId>

  <version>0.1.0</version>

</dependency>

 

You can then create Sling Model classes implementing the ComponentDataElement interface:

 

@Model(adaptables = Resource.class, resourceType = {"myapp/components/myresource" }, adapters = ComponentDataElement.class)
public class CustomDataElement implements ComponentDataElement {

For every class, you will need to specify the annotation parameters “resourceType” and “adapters”. You can specify any number of resource types, and when AEM encounters a resource of the type specified, it will call your Sling Model.

The WeRetail Reference project contains a number of examples ComponentDataElement classes you can use as a base for your custom implementations. For example, if you wanted to track the video displayed in every instance of the video component you scoped in Step 1, you could create a class like the one below:

/*
*  Copyright 2017 - Perficient
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*      http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package com.perficient.aem.weretail.datalayer;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.models.annotations.Model;

import com.perficient.aem.datalayer.api.Component;
import com.perficient.aem.datalayer.api.ComponentDataElement;
import com.perficient.aem.datalayer.api.DataLayer;

/**
* Adds in the video details for the AEM Mobile Video component into the
* AEMDataLayer
*
* @author danklco
*/
@Model(adaptables = Resource.class, resourceType = {
"mobileapps/components/mobilevideo" }, adapters = ComponentDataElement.class)
public class MobileVideoComponent implements ComponentDataElement {

private final Resource resource;

public MobileVideoComponent(Resource resource) {
this.resource = resource;
}

@Override
public void updateDataLayer(DataLayer dataLayer) {

Component component = new Component();
component.getComponentInfo().setComponentID(resource.getPath());

ValueMap properties = resource.getValueMap();

component.addAttribute("video", properties.get("fileReference", String.class));

dataLayer.addComponent(component);
}

}
This Gist brought to you by gist-it.view rawweretail-reference/src/main/java/com/perficient/aem/weretail/datalayer/MobileVideoComponent.java

Further Support

If you have any questions or comments about the AEM DataLayer, please open an issue on GitHub or message me on Twitter at @klcodanr. As the library matures, I will be building out more documentation and use cases on GitHub so please keep tuned!

 

2:26 PM Permalink

Dan Klco: #AEMRockstar 2017

Posted on Tuesday, March 28, 2017 By

If you haven’t heard already, Adobe Summit NA 2017 is in the books! As a result, we have the inaugural #AEMRockstar winner: Dan Klco from Perficient Digital.

The recorded session should be on the Summit online site for those that attended, with the presentations available for download as a PDF. Each finalist will also share their presentation in an upcoming guest post.

Final Results:

  1. Dan Klco, Perficient Digital
  2. Ruben Reusser, headwire.com, Inc.
  3. Rima Mittal, Sapient
  4. Martin Fitch, Kaiser Permanente
    (tied) Robert Langridge, Dixons Carphone

Looking forward to next year.

1:29 PM Permalink

Rockstar Tips & Tricks for AEM Forms

Posted on Wednesday, March 22, 2017 By

 

AEM Rockstar at 2017 Adobe Summit

This year over 12,000 people, including attendees from 1,600 Partners, will be at Adobe Summit, making it the largest Summit ever. Over 200 sessions and labs are held during Summit, including the AEM Rockstar session. This year’s AEM Rockstar session features five winners who submitted their favorite Tips & Tricks for working with Adobe Experience Manager. In upcoming weeks, come back here to see more posts detailing the best tips & tricks from the five AEM Rockstar winners and some of the runners-up.

Todays’s guest post is written by AEM Rockstar runner-up Gary Howell, who is a Sr. Development Manager at iCiDIGITAL, a digital agency in Raleigh, NC that specializes in AEM. Gary has expertise in Adobe CQ5, Java, OSGi and Sling and has extensive frontend development and server-side coding experience. 

Five Tips and Tricks to use AEM Forms More Effectively

Forms are a part of nearly every site on the web. From Fortune 100 companies to the pizza place down the street.

There are many different form solutions you can use on your site, but for many of them you must install a plug-in or go through a complex set-up. However, if you are using an AEM platform, you have the benefits of AEM Forms, allowing users to easily create, manage, and track forms on their site.

There is a lot of good documentation on AEM Forms on the Adobe site, but I figured I’d save you some time by showing you five tips and tricks that my team and I have found to use AEM Forms more effectively.

1)    Form Fragments: Form fragments are most commonly used when you have sections or part of a form you want to reuse on multiple forms. They allow you to easily create part of a form – such as a signature – as a form fragment. You can then reference that specific form fragment on other forms across your site. The power of form fragments is that if you modify a piece of your signature form fragment, for example, the year, you have to change it only once and it will change on all your forms.

2)    Rule Editor: Normally you need to write custom code to execute specific rules on a form such as showing, hiding, validating a field, or disabling a piece of the form. But AEM Forms comes with a rule editor that allows you to easily add this functionality. For example, you can add a rule so that when a user selects a checkbox to have their billing address the same as their home address, it will prefill the billing address with the values they previously entered. Cutting down on the time a user spends on your form means getting one step closer to making a conversion.

 

3)  E-Sign: One of the major pain points with forms on the web – and one that halts conversions – is when the user has to print out a form, sign it and then resend it to you. With AEM forms, you no longer have to do that. AEM Forms comes out of the box with the E-Sign function to enable authors to create forms that can be safely and securely signed by designated users online, with no printing needed.

4)    Form Submission: If you’re managing multiple sites or have a fairly complex site, this feature can be one of the most important. AEM Forms allows developers to easily submit forms in a variety of different ways. For example, you can develop a servlet that submits to a REST endpoint that sends data to your SalesForce instance. Or when a user fills out a form, you can kick off a workflow that notifies a user group that there are new submissions in their inbox, so they can quickly get in touch with their users.

5) Output Service: Outputting forms in various formats such as PDF, PNG, or in a custom format has always been a challenge. Luckily with AEM Forms output service you have an API you can tap into to easily output your forms in a variety of formats. Not only does the output service allow you to generate printable PDFs, but it supports output design features of Adobe LiveCycle Designer ES4 – a key feature for anyone coming from a LiveCycle instance to AEM Forms.

With the release of AEM Forms, you no longer need to create a completely custom solution on your own, thereby reducing the difficulty of upgrading and maintaining your library of forms. AEM Forms frequently comes out with new releases, and each one has new enhancements and features. Keep a look out for what AEM Forms has to offer in the future!

3:42 PM Permalink