Posts Tagged “How To”

Handle form submission using AdapterFactory in Adobe CQ (AEM) OSGi Component

In this article, I will be addressing 2 issues: how to efficiently handle form submission map data in Java and how the AdapterFactory get implemented in Adobe CQ (AEM). How to efficiently handle form submission map data in Java You need 1 servlet, 1 service, and 2 classes: FormSubmissionHandlerServlet, FormSubmissionHandlerService, MyCustomClass, and MyCustomClassAdapterFactory FormSubmissionHandlerServlet is the main service that handles the HTTP request (AJAX request) and dispatches the work for the right candidate class that designed to handle...

Client-side custom form validation and submission in Adobe CQ

In this article, I'm going to discuss on how I integrated and implemented jQuery Form Validator and jQuery Form for handling form validation and submission with Adobe CQ5 (AEM). Assumption (for the sake of this example): Your CQ application/project name is: myapplication We have 3 different clientlibs categories: myapplication.jquery, myapplication.components (embeds myapplication.components.apps), and myapplication.components.apps (this category is for the clientlibs located in the apps level). The location for the 3 clientlibs are: /etc/designs/myapplication/jquery, /etc/designs/myapplication/components, /apps/myapplication/components/{component_name}/clientlibs. We include clientlibs in the CQ page...

Modify the OOTB LinkChecker Config

I've come into the issue recently of needing to modify the prefix and suffix for invalid links detected by the linkchecker. This seemingly simple task is unfortunately not as easy as overlaying the /libs/cq/linkchecker/config.author/invalid to /apps/cq/linkchecker/config.author/invalid. For reasons unknown (to me at least) the standard overlay does not work for this type of update. Instead, after digging into the code, I found this information: REQUEST_ATTRIBUTE_NAME = LinkCheckerSettings.class.getName(); LinkCheckerSettings settings = (LinkCheckerSettings)request.getAttribute(REQUEST_ATTRIBUTE_NAME); The above lines indicate...

Hide/Show parsys on the fly with JavaScript

It is relatively painful to deal with tabs, accordion, or carousel component. Especially when we want to enhance content author experience. Here’s a use case to illustrate to you what I meant: We need to build a tabs component. We want author to manage tabs’ content on the page (not via child page or a separate page). We want author to drag and drop any component into any tab’s content they wish. Bug The screenshots...

CQ Dialog - Generate dynamic rootPath with ExtJS Plugin

This article will shows you how to: one write ExtJS plugin and calls it in CQ dialog and two generating rootPath with ExtJS plugin. We know that with xtype pathfield, we can set rootPath value to any location we want. The drawback is that it is static. If we set rootPath to /content, we fall into providing “no so good author experience” as content author needs to click through pages list to get to the...

How to Manage Field Dependencies in a CQ Dialog

I'm working on a front-end project with some relatively complex UI requirements for author dialog. The author UI requires field dependency. A set of fields is shown or hidden based on a certain selection author makes. After getting a working codes finalized, I thought that it is worth sharing with the community. Sample use case for field dependency: As a content author, I would like to be able to build a grid of maximum 12...

Changing a CQ Component's Design Path

Usually, the default location used by the CQ Designs configuration works, however there are cases where you may want to set the designs to exist at a different location. For example, you may want multiple components to share a configuration or have all of the instances of a component on a site share the same configuration.CQ provides the EditConfig object which can be used to configure how the edit dialog is loaded in CQ.To configure your design...

2 SlingHttpServletRequests walk up to a WhiteBoard...

Recently while creating a Servlet - which I have done hundreds of times on many a CQ based projects - the Default Get Servlet was getting resolved for my request.  I added logging, made sure the SCR name property was populated, round and round I go...  Unlike Stewart the GEICO mascot, I was not yelling "Weee!"  Quite the opposite.After bugging my compadre to have an extra set of eyes on the problem, and check to...

You sunk my content path!

Juggling content from environment to environment is quite frankly a pain in the butt. PROD back to QA, QA back to DEV, DEV back to my personal CQ instance. The need to be concerned with overwriting content along the way. QA people will have their environment setup for regression testing, new testing, etc. Developers will have their tests and POC's setup on their own environments and DEV. You sometimes need to move content from QA...

A CQ Dev Architecture on AWS Rejoinder

Why would you spend the time creating an AWS instance?DISASTER RECOVERY.When consulting on the projects that I am assigned to, I require the security of mind that if my CQ instance dies, I have a way to rebuild it in minutes not hours.  Not just the "base install" but all of my configurations as well.  I need the complete "environment" state preserved to be potentially reconstituted at a moments notice.  This keeps the client happy,...

CQ Dev Architecture #01 - We're Building What?

In this blog post, and the subsequent 6 or so we will discuss one possible way of building a complete CQ development environment, "DevOps", development architecture, or whatever moniker you prefer.  To roughly outline this a bit for you:What we are building (this post)Create yourself an AWS AMINeeded Servers and their ConfigurationIDE Setup - EclipseMaven POM creation, organization, and CQ ProjectsCI / Jenkins Setup, configuration and build projectsWhat I don't like about my setupSome of...

Why does my TextImage Resource Type Keep Changing!?

On my current project, we ran into a very weird issue where the dialog kept changing when user's dragged images into the TextImage component we overrode from the foundation TextImage component.  Specifically, this only seemed to happen when user's dragged images into the component inline. After doing some investigation, I found that the sling:resourceType on the nodes was changing when the image was dragged into the component.  The culprit is the CQ Edit Configuration in the...

Captains Log, Stardate 1210.9: Where the heck are my CQ Logs

The usual way for viewing remote CQ logs seem pretty barbaric and kludgy to me.  Cat, tail, VI, less, and a partridge in a pear tree.  They all require way too many steps, especially if I am in the heat of the development cycle.  If I am leisurely browsing through the park one day trying to look at my logs, and I'm not in a hurry, they will do.  But I like the solution below...

Why Aren't My Public Events Working?

Creating widgets with Public Events and other widget JavaScript functionality allows for the creation of extremely powerful and user friendly dialogs.  Unfortunately, it can be difficult and frustrating to figure out what is the cause when the functions fail to work.Often, Public Events won't fire and there will be no indication in the console or errors as to why.  Here are some tips which may make it easier to figure out why your Public Event...

Workflow Launcher Blues

When creating workflow launchers I recently thought it a good idea to organize them within the /etc/workflow/launcher/config node by creating sub-node's to contain the customized launcher's organized by company name. Given the fact that the models support this, I figured this would be similar.  The only need, I thought, similar to the model sub-nodes is that the subnode of config would have to be of the same type as the config node itself.  With the...

Increasing Recent Requests in the Felix Console

I argued with myself for some time before commiting to writing this post.  Part of me thought it kind of silly to post such a thing.  Then I reflected on the hour or so I wandered around trying to figure out how to get this darned thing to do what I needed it to.  So, now you won't have to wonder how the heck to get this to work properly.  This was tested on CQ...

Releasing an Adobe CQ5 Project with Apache Maven

Apache Maven's release plugin is a powerful tool for automatically incrementing version, tagging code and creating a release. Unfortunately, this plugin is not very forgiving and doesn't do a good job of telling you what you did wrong when it fails. Setting up Maven to release your CQ5 project can seem daunting, but if you follow a few simple rules it can be easy to set up and save you a ton of time in the...

Dumping CQ Configuration

Often when providing remote support, you may want to send a complete snapshot of a CQ instance's configuration and state to others to help debugging.  Generating a report of the complete status of the OSGi configuration, environment state and logs is as easy as invoking a single url. The OSGi console will generate a report of the following items when you invoke: {SERVER}:{PORT}/system/console/config/configuration-status.zipAll Log FilesWire AdminThreadsSystem PropertiesSling Thread PoolsSling SettingsSling Servlet FiltersSling Scheduler JobsSling Resource Resolver...

Creating a CQ 5.5.x ClientContext Compatible JSONP Servlet

The bulk of what needs to be done for creating a JSONP servlet isn't much different than creating a POJEES - 'Plain Old JavaEE Servlet'.  In fact, the servlet I created ran under Tomcat 6.0.38. So we wont cover any of the Servlet method names implemented/overridden or configuration of the Servlet. The first problem I had was figuring out what the content type should be.  This took some digging, but the following header finally got...

JVM Remote JMX Monitoring - Part 2

The last post talked to the ability to connect to a "remote" JVM, that is, a JVM not running behind a firewall.  This could either be a home or corporate network.   The key point being that all TCP/IP ports on the machine running the JVM are accessible by another machine that will be running JConsole or JVisualVM.This post, however, covers accessing a JVM behind a firewall - specifically AWS.  This means that only certain ports...

Sending Email with the Adobe CQ API

Sending emails through Adobe CQ can be easy, however there really isn't an example which brings the entire process together.  This blog post will guide you through the process of configuring Adobe CQ to send email, creating a component for sending email, creating an email template and finally creating a servlet which will send the email.First, though, what are the benefits of the Adobe CQ Email API?  The Adobe CQ API provides a method for...

JVM Remote JMX Monitoring

Setting this up will allow the use of JConsole and JVisualVM to be used for remote monitoring.Benefits: First, running these tools remotely reduces the overall CPU and memory overhead on the remote box.  Second, you do not need physical access to the system to perform monitoring.You should be sensitive to the following: security issues around allowing remote access to a JVM, and governance with IT departments to prevent too many connections to the remote JVM....

Maven CQ5 Package Build: Updating Properties.xml

This article describes the process of adding and automatically updating a CQ5 Package properties.xml as a part of a Maven build.Why do I need a Properties.xml?Certain CQ5.4 Hotfixes are known to cause issues where packages without a properties.xml will not install properly.  If you attempt to install a package into a CQ instance with the affected Hotfix, you will see this error:java.lang.NullPointerException at com.day.jcr.vault.packaging.impl.InstallHookProcessor.registerHooks(InstallHookProcessor.java:80) at com.day.jcr.vault.packaging.impl.ZipVaultPackage.prepareExtract(ZipVaultPackage.java:303) at com.day.jcr.vault.packaging.impl.JcrPackageImpl.extract(JcrPackageImpl.java:341) at com.day.jcr.vault.packaging.impl.JcrPackageImpl.install(JcrPackageImpl.java:314) at com.day.crx.packaging.impl.J2EEPackageManager.consoleInstall(J2EEPackageManager.java:304) at com.day.crx.packaging.impl.J2EEPackageManager.doPost(J2EEPackageManager.java:152) at...