Skip to content

Instantly share code, notes, and snippets.

View ConfigurationModel.java
package aem.training.core.models;
import aem.training.core.config.GoogleReCaptchaConfiguration;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.caconfig.ConfigurationBuilder;
import org.apache.sling.caconfig.resource.ConfigurationResourceResolver;
import org.apache.sling.models.annotations.DefaultInjectionStrategy;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.OSGiService;
View GoogleReCaptchaConfiguration.java
package aem.training.core.config;
import org.apache.sling.caconfig.annotation.Configuration;
import org.apache.sling.caconfig.annotation.Property;
/**
* Context Aware configuration for Google ReCaptcha.
*
* @author shivani Date Created: 31 January 2020
View CAConfigModel.java
package aem.training.core.models;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.caconfig.resource.ConfigurationResourceResolver;
import org.apache.sling.models.annotations.DefaultInjectionStrategy;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.OSGiService;
import org.apache.sling.models.annotations.injectorspecific.SlingObject;
@sgaem
sgaem / showhidetab.js
Created Sep 4, 2018
This JS file is used to hide and show tabs based on drop down selection.
View showhidetab.js
/**
* Extension to the standard dropdown/select component. It enabled hidding/unhidding of tabs based on the
* selection made in the dropdown/select.
*
* How to use:
*
* - add the class cq-dialog-dropdown-tab-showhide to the dropdown/select element
* - add the data attribute cq-dialog-dropdown-tab-showhide-target to the dropdown/select element, value should be the
* selector, usually a specific class name, to find all possible target elements that can be shown/hidden.
@sgaem
sgaem / PageRedirectServlet.java
Last active Aug 8, 2019
The servlet that overrides OOTB of the PageRedirectServlet.java
View PageRedirectServlet.java
package com.aem.project.core.servlets;
import com.day.cq.wcm.api.WCMMode;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
View SampleJbossApplication.java
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
public class SampleJbossApplication extends SpringBootServletInitializer {
@sgaem
sgaem / UserAccountDetail.java
Created May 31, 2019
UserAccountDetail.java is the implementation of Factory OSGI Configuration.
View UserAccountDetail.java
package com.poc.osgiannotation.core.servlets;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Modified;
import org.osgi.service.metatype.annotations.Designate;
@Component(service=UserAccountDetail.class,immediate=true)
@Designate(ocd = UserConfiguration.class,factoy=true)
public class UserAccountDetail {
@sgaem
sgaem / Multifield.js
Last active Mar 29, 2019
This Multifield.js is working with all the widgets like drop-down and checkbox functionality.
View Multifield.js
(function ($, $document) {
var DATA_EAEM_NESTED = "data-eaem-nested";
var CFFW = ".coral-Form-fieldwrapper";
function isSelectOne($field){
return !_.isEmpty($field) && ($field.prop("type") === "select-one");
}
function setSelectOne($field, value){
var select = $field.closest(".coral-Select").data("select");
if(select){
select.setValue(value);
@sgaem
sgaem / DropDownServlet.java
Created Jan 12, 2019
This gist demonstrates how to dynamically populate values based on different conditions in AEM.
View DropDownServlet.java
package com.aem.project.core.servlets;
import com.adobe.cq.commerce.common.ValueMapDecorator;
import com.adobe.granite.ui.components.ds.DataSource;
import com.adobe.granite.ui.components.ds.SimpleDataSource;
import com.adobe.granite.ui.components.ds.ValueMapResource;
import com.day.cq.wcm.api.Page;
import com.day.crx.JcrConstants;
import org.apache.commons.collections4.iterators.TransformIterator;
import org.apache.sling.api.SlingHttpServletRequest;
@sgaem
sgaem / DropDownServlet.java
Created Jan 12, 2019
This gist shows the dynamic population of drop down using datasource in AEM.
View DropDownServlet.java
package com.aem.project.core.servlets;
import com.adobe.cq.commerce.common.ValueMapDecorator;
import com.adobe.granite.ui.components.ds.DataSource;
import com.adobe.granite.ui.components.ds.SimpleDataSource;
import com.adobe.granite.ui.components.ds.ValueMapResource;
import com.day.crx.JcrConstants;
import org.apache.commons.collections4.iterators.TransformIterator;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;