com.jgeppert.struts2.jquery.components.Slider Maven / Gradle / Ivy
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.jgeppert.struts2.jquery.components;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.views.annotations.StrutsTag;
import org.apache.struts2.views.annotations.StrutsTagAttribute;
import org.apache.struts2.views.annotations.StrutsTagSkipInheritance;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.Collection;
/**
*
*
* A tag that creates an Slider.
*
*
*
* Examples
*
*
*
* <sj:slider id="myslider" name="myslider"/>
*
*
*
*
* <sj:slider id="myslider2" name="myslider2" value="40" displayValueElement="displayvaluespan" min="20" max="200" animate="true" step="5" cssStyle="margin: 10px;"/>
*
*
*
* @author Johannes Geppert
*/
@StrutsTag(name = "slider", tldTagClass = "com.jgeppert.struts2.jquery.views.jsp.ui.SliderTag", description = "Render a Slider", allowDynamicAttributes = true)
public class Slider extends AbstractTopicsBean {
public static final String JQUERYACTION = "slider";
public static final String TEMPLATE = "slider";
public static final String TEMPLATE_CLOSE = "slider-close";
private static final String PARAM_ANIMATE = "animate";
private static final String PARAM_MAX = "max";
private static final String PARAM_MIN = "min";
private static final String PARAM_ORIENTATION = "orientation";
private static final String PARAM_STEP = "step";
private static final String PARAM_DISPLAY_VALUE_ELEMENT = "displayValueElement";
private static final String PARAM_ON_SLIDE_TOPICS = "onSlideTopics";
private static final String PARAM_ARRAY_VALUE = "arrayValue";
private static final String PARAM_RANGE = "range";
private static final String PARAM_VALUE = "value";
private static final String PARAM_WIDGETID = "widgetid";
private static final String ID_PREFIX_SLIDER = "slider_";
protected String animate;
protected String max;
protected String min;
protected String orientation;
protected String range;
protected String step;
protected String displayValueElement;
protected String onSlideTopics;
public Slider(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
super(stack, request, response);
}
public String getDefaultOpenTemplate() {
return TEMPLATE;
}
protected String getDefaultTemplate() {
return TEMPLATE_CLOSE;
}
public void evaluateParams() {
super.evaluateParams();
addParameter(PARAM_JQUERY_ACTION, JQUERYACTION);
addParameterIfPresent(PARAM_ANIMATE, this.animate, Boolean.class);
addParameterIfPresent(PARAM_MAX, this.max, Integer.class);
addParameterIfPresent(PARAM_MIN, this.min, Integer.class);
addParameterIfPresent(PARAM_ORIENTATION, this.orientation);
addParameterIfPresent(PARAM_RANGE, this.range);
addParameterIfPresent(PARAM_STEP, this.step, Integer.class);
addParameterIfPresent(PARAM_DISPLAY_VALUE_ELEMENT, this.displayValueElement);
addParameterIfPresent(PARAM_ON_SLIDE_TOPICS, this.onSlideTopics);
Object valueObject = null;
String strValue = null;
if (value != null) {
strValue = value;
} else {
if (name != null) {
strValue = name;
}
}
if (strValue != null) {
valueObject = findValue(strValue);
}
if (valueObject == null && strValue != null) {
valueObject = strValue;
}
if (valueObject != null) {
if (valueObject instanceof String && ((String) valueObject).startsWith("[")) {
addParameter(PARAM_ARRAY_VALUE, findString(strValue));
addParameter(PARAM_RANGE, Boolean.TRUE.toString());
} else if (valueObject instanceof Collection>) {
@SuppressWarnings("unchecked")
Collection
© 2015 - 2024 Weber Informatics LLC | Privacy Policy