Skip to content

Instantly share code, notes, and snippets.

View markdaugherty's full-sized avatar

Mark Daugherty markdaugherty

View GitHub Profile
@markdaugherty
markdaugherty / CacheableRenditions.java
Last active April 24, 2020 13:51
AEM Cacheable Renditions Example Usage
import com.avionos.aem.assets.cacheablerenditions.api.CacheableRendition;
import com.day.cq.dam.api.Asset;
// get cacheable rendition from rendition
final CacheableRendition cacheableRendition = resourceResolver
.getResource("/content/dam/avionos/images/one.png")
.adaptTo(Asset.class)
.getRendition("cq5dam.thumbnail.48.48.png")
.adaptTo(CacheableRendition.class);
import com.citytechinc.cq.component.annotations.Component
import com.citytechinc.cq.component.annotations.DialogField
import com.citytechinc.cq.component.annotations.Option
import com.citytechinc.cq.component.annotations.widgets.PathField
import com.citytechinc.cq.component.annotations.widgets.Selection
import com.citytechinc.cq.component.annotations.widgets.Switch
import com.citytechinc.cq.component.annotations.widgets.TextField
import com.icfolson.aem.library.core.components.AbstractComponent
import com.icfolson.aem.library.core.constants.PathConstants
import com.icfolson.aem.multicompositeaddon.widget.MultiCompositeField
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0" fileName="_cq_dialog.xml" jcr:primaryType="nt:unstructured" jcr:title="Header" mode="edit" sling:resourceType="cq/gui/components/authoring/dialog">
<content jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/container">
<layout jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/layouts/tabs"/>
<items jcr:primaryType="nt:unstructured">
<SecondaryNavigation xmlns:cq="http://www.day.com/jcr/cq/1.0" cq:showOnCreate="{Boolean}true" jcr:primaryType="nt:unstructured" jcr:title="Secondary Navigation" sling:resourceType="granite/ui/components/foundation/section">
<layout jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/layouts/fixedcolumns"/>
<items jcr:primaryType="nt:unstructured">
<column jcr:primaryType="nt:unstructured" sling:resou
@markdaugherty
markdaugherty / dialog.xml
Created January 28, 2013 19:32
CQ5 - disable dialog field when content is loaded
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" jcr:primaryType="cq:Dialog"
xtype="dialog">
<listeners jcr:primaryType="nt:unstructured"
loadcontent="function(dialog) {
// call servlet or perform arbitrary javascript functions
dialog.getField('./operator').disable();
}" />
<items jcr:primaryType="cq:WidgetCollection">
@markdaugherty
markdaugherty / pom.xml
Last active December 11, 2015 17:58
Maven POM configuration for OSGi Bundle Status plugin.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>com.citytechinc.cqlibrary</groupId>
<artifactId>cq5-library</artifactId>
<version>4.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="cq:Dialog" xtype="dialog">
<items jcr:primaryType="cq:WidgetCollection">
<tabs jcr:primaryType="cq:TabPanel">
<items jcr:primaryType="cq:WidgetCollection">
<first jcr:primaryType="nt:unstructured" title="Form" xtype="panel">
<items jcr:primaryType="cq:WidgetCollection">
<name jcr:primaryType="cq:Widget" fieldLabel="Name" name="./name" xtype="textfield" allowBlank="{Boolean}false"
validator="function(value) {
@markdaugherty
markdaugherty / AbstractValidatorServlet.java
Created April 15, 2012 15:56
Complex validation of CQ5 dialog fields using a custom Sling servlet.
import java.io.IOException;
import java.util.Collections;
import javax.servlet.ServletException;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
import org.codehaus.jackson.JsonFactory;
import org.codehaus.jackson.JsonGenerationException;