All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.adobe.aemds.guide.common.GuideDropDownList Maven / Gradle / Ivy

/*************************************************************************
 *
 * ADOBE CONFIDENTIAL
 * __________________
 *
 *  Copyright 2014 Adobe Systems Incorporated
 *  All Rights Reserved.
 *
 * NOTICE:  All information contained herein is, and remains
 * the property of Adobe Systems Incorporated and its suppliers,
 * if any.  The intellectual and technical concepts contained
 * herein are proprietary to Adobe Systems Incorporated and its
 * suppliers and may be covered by U.S. and Foreign Patents,
 * patents in process, and are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Adobe Systems Incorporated.
 **************************************************************************/

package com.adobe.aemds.guide.common;

import com.adobe.aemds.guide.utils.GuideConstants;
import com.day.cq.wcm.foundation.forms.FormsConstants;
import com.day.cq.wcm.foundation.forms.FormsHelper;
import org.apache.commons.lang.StringUtils;
import org.apache.sling.api.resource.Resource;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.List;

/**
 * GuideDropDownList encapsulates basic properties of the Adaptive Forms Drop Down Component.
 * Few are listed below:
 * 
    *
  • Options of the dropdown configured during authoring *
  • multiple selection checkbox configured during authoring *
* * * @since 6.0 */ public class GuideDropDownList extends GuideField { // Flag to check if it is the first optgroup in the drop down list. private boolean isFirstOptGroup = true; /** * Returns the options configured for the dropdown list component during authoring * @return Map Map where keys are the values of the options in the dropdown list and the values in the map are the text of corresponding option. */ public Map getOptions() { String[] options = null; //Populate Options from Options Load Path. final String loadPath = resourceProps.get(FormsConstants.ELEMENT_PROPERTY_OPTIONS_LOAD_PATH, ""); if ( loadPath.length() > 0 ) { // check if loadPath is defined and try this as an absolute path final Resource resLoadPath = slingRequest.getResourceResolver().getResource(loadPath); if ( resLoadPath != null ) { options = resLoadPath.adaptTo(String[].class); } } //Populate Options from Options Resource. if(options == null) { options = (String[]) resourceProps.get(FormsConstants.ELEMENT_PROPERTY_OPTIONS,String[].class); } if (options == null) { return null; } Map result = new LinkedHashMap(); for(int i=0; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy