Skip to content

Instantly share code, notes, and snippets.

@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 / UserAccountDetail.java
Created Jul 30, 2017
This is the implementation class of UserConfiguration Interface.
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)
public class UserAccountDetail {
@sgaem
sgaem / UserConfiguration.java
Created Jul 30, 2017
This interface is used as an OSGi annotations in AEM 6.3
View UserConfiguration.java
package com.poc.osgiannotation.core.servlets;
import org.osgi.service.metatype.annotations.AttributeDefinition;
import org.osgi.service.metatype.annotations.AttributeType;
import org.osgi.service.metatype.annotations.ObjectClassDefinition;
import org.osgi.service.metatype.annotations.Option;
@ObjectClassDefinition(name = "SGAEM User Account Configuration", description = "Configure the user Details")
public @interface UserConfiguration {
View RequestPassword.java
package com.aem.sgaem.project.servlets;
import com.adobe.cq.account.api.AccountManagementService;
import java.io.IOException;
import javax.jcr.RepositoryException;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.sling.SlingServlet;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.SlingAllMethodsServlet;
@sgaem
sgaem / TestComponentModel.java
Last active Jun 10, 2017
This is the java class which is used as a sing model just to fetch the value of the properties.
View TestComponentModel.java
package com.mycompany.myproject.sling.models;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.DefaultInjectionStrategy;
import org.apache.sling.models.annotations.Model;
import javax.inject.Inject;
import javax.inject.Named;
@Model(adaptables = Resource.class, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
@sgaem
sgaem / TestComponentModel.java
Last active Jun 10, 2017
This is the TestComponentModel.java, which can be used as sling Model Exporters.
View TestComponentModel.java
package com.mycompany.myproject.sling.models;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.DefaultInjectionStrategy;
import org.apache.sling.models.annotations.Exporter;
import org.apache.sling.models.annotations.ExporterOption;
import org.apache.sling.models.annotations.Model;
import javax.inject.Inject;
import javax.inject.Named;
View limit.js
$(document).on("dialog-ready", function () {
$(".js-coral-Multifield-add").click(function() {
var field = $(this).parent();
var size = field.attr("data-limit");
if (size) {
var ui = $(window).adaptTo("foundation-ui");
var totalLinkCount = $(this).prev('ol').children('li').length;
if (totalLinkCount >= size) {
ui.alert("Warning", "Maximum " + size + " links are allowed!", "notice");
return false;
@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);
View POST.html
<sly data-sly-include="/libs/foundation/components/account/requestconfirmation/requestconfirmation.jsp" />
View newPassword.html
<form action="${resource.path}.html" method="post">
<ul class="form-style-1">
<h1>Change Password</h1>
<li>
<label>New Password <span class="required">*</span></label>
<input type="password" name="passwordreset"/>
</li>
<li>
<label>Confirm Password <span class="required">*</span></label>
<input type="password" name="passwordreset_confirm"/>