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 java.util.Arrays;
import java.util.Collection;
import java.util.Random;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.views.annotations.StrutsTag;
import org.apache.struts2.views.annotations.StrutsTagAttribute;
import org.apache.struts2.views.annotations.StrutsTagSkipInheritance;
import com.opensymphony.xwork2.util.ValueStack;
/**
*
*
* 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";
final private static transient Random RANDOM = new Random();
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("jqueryaction", JQUERYACTION);
if (animate != null) addParameter("animate", findValue(animate, Boolean.class));
if (max != null) addParameter("max", findValue(max, Integer.class));
if (min != null) addParameter("min", findValue(min, Integer.class));
if (orientation != null) addParameter("orientation", findString(orientation));
if (range != null) addParameter("range", findString(range));
if (step != null) addParameter("step", findValue(step, Integer.class));
if (displayValueElement != null) addParameter("displayValueElement", findString(displayValueElement));
if (onSlideTopics != null) addParameter("onSlideTopics", findString(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("arrayValue", findString(strValue));
addParameter("range", "true");
}
else if (valueObject instanceof Collection>)
{
@SuppressWarnings("unchecked")
Collection
© 2015 - 2025 Weber Informatics LLC | Privacy Policy