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

net.bootsfaces.component.shake.Shake Maven / Gradle / Ivy

There is a newer version: 2.0.1
Show newest version
/**
 *  Copyright 2014-2017 Riccardo Massera (TheCoder4.Eu), Dario D'Urzo and Stephan Rauh (http://www.beyondjava.net).
 *  
 *  This file is part of BootsFaces.
 *  
* Licensed 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 net.bootsfaces.component.shake;

import java.util.Map;

import javax.el.ValueExpression;
import javax.faces.component.FacesComponent;
import javax.faces.component.UICommand;
import javax.faces.component.behavior.ClientBehaviorHolder;
import net.bootsfaces.C;

import net.bootsfaces.component.ajax.IAJAXComponent;
import net.bootsfaces.listeners.AddResourcesListener;
import net.bootsfaces.utils.BsfUtils;

/** This class holds the attributes of <b:shake />. */
@FacesComponent(Shake.COMPONENT_TYPE)
public class Shake extends UICommand implements ClientBehaviorHolder, IAJAXComponent {

	public static final String COMPONENT_TYPE = C.BSFCOMPONENT + ".shake.Shake";

	public static final String COMPONENT_FAMILY = C.BSFCOMPONENT;

	public static final String DEFAULT_RENDERER = "net.bootsfaces.component.shake.Shake";

	public Shake() {
		AddResourcesListener.addResourceToHeadButAfterJQuery("bsf", "jq/mobile/shake.js");
		AddResourcesListener.addThemedCSSResource("core.css");
		//AddResourcesListener.addThemedCSSResource("bsf.css");
		setRendererType(DEFAULT_RENDERER);
	}

	public String getFamily() {
		return COMPONENT_FAMILY;
	}

	@Override
	public Map getJQueryEvents() {
		return null;
	}

	/**
	 * Returns the subset of the parameter list of jQuery and other non-standard JS callbacks which is sent to the server via AJAX.
	 * If there's no parameter list for a certain event, the default is simply null.
	 * 
	 * @return A hash map containing the events. May be null.
	 */
	@Override
	public Map getJQueryEventParameterListsForAjax() {
		return null;
	}

	/**
	 * Returns the parameter list of jQuery and other non-standard JS callbacks.
	 * If there's no parameter list for a certain event, the default is simply "event".
	 * 
	 * @return A hash map containing the events. May be null.
	 */
	@Override
	public Map getJQueryEventParameterLists() {
		return null;
	}

	@Override
	@Deprecated
	public String getOnclick() {
		throw new IllegalAccessError("The onclick attribute hasn't been implemented. Please use onshake instead.");
	}

	/**
	 * Manage EL-expression for snake-case attributes
	 */
	public void setValueExpression(String name, ValueExpression binding) {
		name = BsfUtils.snakeCaseToCamelCase(name);
		super.setValueExpression(name, binding);
	}

	protected enum PropertyKeys {
		ajax, disabled, interval, oncomplete, onshake, process, threshold, update;
		String toString;

		PropertyKeys(String toString) {
			this.toString = toString;
		}

		PropertyKeys() {
		}

		public String toString() {
			return ((this.toString != null) ? this.toString : super.toString());
		}
	}

	/**
	 * Whether the Button submits the form with AJAX. 

* @return Returns the value of the attribute, or , false, if it hasn't been set by the JSF file. */ public boolean isAjax() { return (boolean) (Boolean) getStateHelper().eval(PropertyKeys.ajax, false); } /** * Whether the Button submits the form with AJAX.

* Usually this method is called internally by the JSF engine. */ public void setAjax(boolean _ajax) { getStateHelper().put(PropertyKeys.ajax, _ajax); } /** * Disables the input element, default is false.

* @return Returns the value of the attribute, or , false, if it hasn't been set by the JSF file. */ public boolean isDisabled() { return (boolean) (Boolean) getStateHelper().eval(PropertyKeys.disabled, false); } /** * Disables the input element, default is false.

* Usually this method is called internally by the JSF engine. */ public void setDisabled(boolean _disabled) { getStateHelper().put(PropertyKeys.disabled, _disabled); } /** * Specifies the delay (in milliseconds) between each slide.

* @return Returns the value of the attribute, or 500, if it hasn't been set by the JSF file. */ public int getInterval() { return (int) (Integer) getStateHelper().eval(PropertyKeys.interval, 500); } /** * Specifies the delay (in milliseconds) between each slide.

* Usually this method is called internally by the JSF engine. */ public void setInterval(int _interval) { getStateHelper().put(PropertyKeys.interval, _interval); } /** * JavaScript to be executed when ajax completes with success.

* @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file. */ public String getOncomplete() { return (String) getStateHelper().eval(PropertyKeys.oncomplete); } /** * JavaScript to be executed when ajax completes with success.

* Usually this method is called internally by the JSF engine. */ public void setOncomplete(String _oncomplete) { getStateHelper().put(PropertyKeys.oncomplete, _oncomplete); } /** * A method binding expression referring to a method for handling a valuechangeevent.

* @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file. */ public String getOnshake() { return (String) getStateHelper().eval(PropertyKeys.onshake); } /** * A method binding expression referring to a method for handling a valuechangeevent.

* Usually this method is called internally by the JSF engine. */ public void setOnshake(String _onshake) { getStateHelper().put(PropertyKeys.onshake, _onshake); } /** * Comma or space separated list of ids or search expressions denoting which values are to be sent to the server.

* @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file. */ public String getProcess() { return (String) getStateHelper().eval(PropertyKeys.process); } /** * Comma or space separated list of ids or search expressions denoting which values are to be sent to the server.

* Usually this method is called internally by the JSF engine. */ public void setProcess(String _process) { getStateHelper().put(PropertyKeys.process, _process); } /** * Specifies the sensitivity of the skae detector.

* @return Returns the value of the attribute, or 15, if it hasn't been set by the JSF file. */ public int getThreshold() { return (int) (Integer) getStateHelper().eval(PropertyKeys.threshold, 15); } /** * Specifies the sensitivity of the skae detector.

* Usually this method is called internally by the JSF engine. */ public void setThreshold(int _threshold) { getStateHelper().put(PropertyKeys.threshold, _threshold); } /** * Component(s) to be updated with ajax.

* @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file. */ public String getUpdate() { return (String) getStateHelper().eval(PropertyKeys.update); } /** * Component(s) to be updated with ajax.

* Usually this method is called internally by the JSF engine. */ public void setUpdate(String _update) { getStateHelper().put(PropertyKeys.update, _update); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy