net.bootsfaces.component.carouselControl.CarouselControl Maven / Gradle / Ivy
/**
* Copyright 2014-2019 Riccardo Massera (TheCoder4.Eu) 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.carouselControl;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ComponentSystemEvent;
import javax.faces.event.ListenerFor;
import javax.faces.event.ListenersFor;
import javax.faces.event.PostAddToViewEvent;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
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.component.ajax.IAJAXComponent2;
import net.bootsfaces.render.Tooltip;
import net.bootsfaces.utils.BsfUtils;
/** This class holds the attributes of <b:carouselControl />. */
@ListenersFor({ @ListenerFor(systemEventClass = PostAddToViewEvent.class) })
@FacesComponent(CarouselControl.COMPONENT_TYPE)
public class CarouselControl extends UICommand
implements net.bootsfaces.render.IHasTooltip, IAJAXComponent, IAJAXComponent2, ClientBehaviorHolder {
public static final String COMPONENT_TYPE = C.BSFCOMPONENT + ".carouselControl.CarouselControl";
public static final String COMPONENT_FAMILY = C.BSFCOMPONENT;
public static final String DEFAULT_RENDERER = "net.bootsfaces.component.carouselControl.CarouselControl";
public CarouselControl() {
Tooltip.addResourceFiles();
setRendererType(DEFAULT_RENDERER);
}
public void setValueExpression(String name, ValueExpression binding) {
name = BsfUtils.snakeCaseToCamelCase(name);
super.setValueExpression(name, binding);
}
public String getFamily() {
return COMPONENT_FAMILY;
}
private static final Collection EVENT_NAMES = Collections.unmodifiableCollection(
Arrays.asList("click", "dblclick", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup"));
/**
* 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 subset of AJAX requests that are implemented by jQuery
* callback or other non-standard means (such as the onclick event of
* b:tabView, which has to be implemented manually).
*
* @return
*/
public Map getJQueryEvents() {
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;
}
public Collection getEventNames() {
return EVENT_NAMES;
}
public String getDefaultEventName() {
return "click";
}
public void processEvent(ComponentSystemEvent event) throws AbortProcessingException {
if (isAutoUpdate()) {
if (FacesContext.getCurrentInstance().isPostback()) {
FacesContext.getCurrentInstance().getPartialViewContext().getRenderIds().add(getClientId());
}
super.processEvent(event);
}
}
protected enum PropertyKeys {
ajax, autoUpdate, delay, direction, disabled, onclick, oncomplete, ondblclick, onerror, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup, onsuccess, process, style, styleClass, tooltip, tooltipContainer, tooltipDelay, tooltipDelayHide, tooltipDelayShow, tooltipPosition, 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);
}
/**
* Setting this flag updates the widget on every AJAX request.
* @return Returns the value of the attribute, or , false, if it hasn't been set by the JSF file.
*/
public boolean isAutoUpdate() {
return (boolean) (Boolean) getStateHelper().eval(PropertyKeys.autoUpdate, false);
}
/**
* Setting this flag updates the widget on every AJAX request.
* Usually this method is called internally by the JSF engine.
*/
public void setAutoUpdate(boolean _autoUpdate) {
getStateHelper().put(PropertyKeys.autoUpdate, _autoUpdate);
}
/**
* Delays the AJAX request.
* @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file.
*/
public String getDelay() {
return (String) getStateHelper().eval(PropertyKeys.delay);
}
/**
* Delays the AJAX request.
* Usually this method is called internally by the JSF engine.
*/
public void setDelay(String _delay) {
getStateHelper().put(PropertyKeys.delay, _delay);
}
/**
* Can take one of the values 'left' and 'right'. Determines whether the carousel scrolls to the next or to the previous image.
* @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file.
*/
public String getDirection() {
return (String) getStateHelper().eval(PropertyKeys.direction);
}
/**
* Can take one of the values 'left' and 'right'. Determines whether the carousel scrolls to the next or to the previous image.
* Usually this method is called internally by the JSF engine.
*/
public void setDirection(String _direction) {
getStateHelper().put(PropertyKeys.direction, _direction);
}
/**
* Boolean value to specify if the button is disabled.
* @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);
}
/**
* Boolean value to specify if the button is disabled.
* Usually this method is called internally by the JSF engine.
*/
public void setDisabled(boolean _disabled) {
getStateHelper().put(PropertyKeys.disabled, _disabled);
}
/**
* The onclick attribute.
* @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file.
*/
public String getOnclick() {
return (String) getStateHelper().eval(PropertyKeys.onclick);
}
/**
* The onclick attribute.
* Usually this method is called internally by the JSF engine.
*/
public void setOnclick(String _onclick) {
getStateHelper().put(PropertyKeys.onclick, _onclick);
}
/**
* JavaScript to be executed when ajax completes.
* @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.
* Usually this method is called internally by the JSF engine.
*/
public void setOncomplete(String _oncomplete) {
getStateHelper().put(PropertyKeys.oncomplete, _oncomplete);
}
/**
* Client side callback to execute when input element is double clicked.
* @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file.
*/
public String getOndblclick() {
return (String) getStateHelper().eval(PropertyKeys.ondblclick);
}
/**
* Client side callback to execute when input element is double clicked.
* Usually this method is called internally by the JSF engine.
*/
public void setOndblclick(String _ondblclick) {
getStateHelper().put(PropertyKeys.ondblclick, _ondblclick);
}
/**
* JavaScript to be executed when ajax results on an error (including both network errors and Java exceptions).
* @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file.
*/
public String getOnerror() {
return (String) getStateHelper().eval(PropertyKeys.onerror);
}
/**
* JavaScript to be executed when ajax results on an error (including both network errors and Java exceptions).
* Usually this method is called internally by the JSF engine.
*/
public void setOnerror(String _onerror) {
getStateHelper().put(PropertyKeys.onerror, _onerror);
}
/**
* Client side callback to execute when a pointer input element is pressed down over input element.
* @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file.
*/
public String getOnmousedown() {
return (String) getStateHelper().eval(PropertyKeys.onmousedown);
}
/**
* Client side callback to execute when a pointer input element is pressed down over input element.
* Usually this method is called internally by the JSF engine.
*/
public void setOnmousedown(String _onmousedown) {
getStateHelper().put(PropertyKeys.onmousedown, _onmousedown);
}
/**
* Client side callback to execute when a pointer input element is moved within input element.
* @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file.
*/
public String getOnmousemove() {
return (String) getStateHelper().eval(PropertyKeys.onmousemove);
}
/**
* Client side callback to execute when a pointer input element is moved within input element.
* Usually this method is called internally by the JSF engine.
*/
public void setOnmousemove(String _onmousemove) {
getStateHelper().put(PropertyKeys.onmousemove, _onmousemove);
}
/**
* Client side callback to execute when a pointer input element is moved away from input element.
* @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file.
*/
public String getOnmouseout() {
return (String) getStateHelper().eval(PropertyKeys.onmouseout);
}
/**
* Client side callback to execute when a pointer input element is moved away from input element.
* Usually this method is called internally by the JSF engine.
*/
public void setOnmouseout(String _onmouseout) {
getStateHelper().put(PropertyKeys.onmouseout, _onmouseout);
}
/**
* Client side callback to execute when a pointer input element is moved onto input element.
* @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file.
*/
public String getOnmouseover() {
return (String) getStateHelper().eval(PropertyKeys.onmouseover);
}
/**
* Client side callback to execute when a pointer input element is moved onto input element.
* Usually this method is called internally by the JSF engine.
*/
public void setOnmouseover(String _onmouseover) {
getStateHelper().put(PropertyKeys.onmouseover, _onmouseover);
}
/**
* Client side callback to execute when a pointer input element is released over input element.
* @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file.
*/
public String getOnmouseup() {
return (String) getStateHelper().eval(PropertyKeys.onmouseup);
}
/**
* Client side callback to execute when a pointer input element is released over input element.
* Usually this method is called internally by the JSF engine.
*/
public void setOnmouseup(String _onmouseup) {
getStateHelper().put(PropertyKeys.onmouseup, _onmouseup);
}
/**
* JavaScript to be executed when ajax completes with success (i.e. there's neither a network error nor a Java exception).
* @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file.
*/
public String getOnsuccess() {
return (String) getStateHelper().eval(PropertyKeys.onsuccess);
}
/**
* JavaScript to be executed when ajax completes with success (i.e. there's neither a network error nor a Java exception).
* Usually this method is called internally by the JSF engine.
*/
public void setOnsuccess(String _onsuccess) {
getStateHelper().put(PropertyKeys.onsuccess, _onsuccess);
}
/**
* 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);
}
/**
* Inline style of the input element.
* @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file.
*/
public String getStyle() {
return (String) getStateHelper().eval(PropertyKeys.style);
}
/**
* Inline style of the input element.
* Usually this method is called internally by the JSF engine.
*/
public void setStyle(String _style) {
getStateHelper().put(PropertyKeys.style, _style);
}
/**
* Style class of this element.
* @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file.
*/
public String getStyleClass() {
return (String) getStateHelper().eval(PropertyKeys.styleClass);
}
/**
* Style class of this element.
* Usually this method is called internally by the JSF engine.
*/
public void setStyleClass(String _styleClass) {
getStateHelper().put(PropertyKeys.styleClass, _styleClass);
}
/**
* The text of the tooltip.
* @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file.
*/
public String getTooltip() {
return (String) getStateHelper().eval(PropertyKeys.tooltip);
}
/**
* The text of the tooltip.
* Usually this method is called internally by the JSF engine.
*/
public void setTooltip(String _tooltip) {
getStateHelper().put(PropertyKeys.tooltip, _tooltip);
}
/**
* Where is the tooltip div generated? That's primarily a technical value that can be used to fix rendering errors in special cases. Also see data-container in the documentation of Bootstrap. The default value is body.
* @return Returns the value of the attribute, or "body", if it hasn't been set by the JSF file.
*/
public String getTooltipContainer() {
return (String) getStateHelper().eval(PropertyKeys.tooltipContainer, "body");
}
/**
* Where is the tooltip div generated? That's primarily a technical value that can be used to fix rendering errors in special cases. Also see data-container in the documentation of Bootstrap. The default value is body.
* Usually this method is called internally by the JSF engine.
*/
public void setTooltipContainer(String _tooltipContainer) {
getStateHelper().put(PropertyKeys.tooltipContainer, _tooltipContainer);
}
/**
* The tooltip is shown and hidden with a delay. This value is the delay in milliseconds. Defaults to 0 (no delay).
* @return Returns the value of the attribute, or 0, if it hasn't been set by the JSF file.
*/
public int getTooltipDelay() {
return (int) (Integer) getStateHelper().eval(PropertyKeys.tooltipDelay, 0);
}
/**
* The tooltip is shown and hidden with a delay. This value is the delay in milliseconds. Defaults to 0 (no delay).
* Usually this method is called internally by the JSF engine.
*/
public void setTooltipDelay(int _tooltipDelay) {
getStateHelper().put(PropertyKeys.tooltipDelay, _tooltipDelay);
}
/**
* The tooltip is hidden with a delay. This value is the delay in milliseconds. Defaults to 0 (no delay).
* @return Returns the value of the attribute, or 0, if it hasn't been set by the JSF file.
*/
public int getTooltipDelayHide() {
return (int) (Integer) getStateHelper().eval(PropertyKeys.tooltipDelayHide, 0);
}
/**
* The tooltip is hidden with a delay. This value is the delay in milliseconds. Defaults to 0 (no delay).
* Usually this method is called internally by the JSF engine.
*/
public void setTooltipDelayHide(int _tooltipDelayHide) {
getStateHelper().put(PropertyKeys.tooltipDelayHide, _tooltipDelayHide);
}
/**
* The tooltip is shown with a delay. This value is the delay in milliseconds. Defaults to 0 (no delay).
* @return Returns the value of the attribute, or 0, if it hasn't been set by the JSF file.
*/
public int getTooltipDelayShow() {
return (int) (Integer) getStateHelper().eval(PropertyKeys.tooltipDelayShow, 0);
}
/**
* The tooltip is shown with a delay. This value is the delay in milliseconds. Defaults to 0 (no delay).
* Usually this method is called internally by the JSF engine.
*/
public void setTooltipDelayShow(int _tooltipDelayShow) {
getStateHelper().put(PropertyKeys.tooltipDelayShow, _tooltipDelayShow);
}
/**
* Where is the tooltip to be displayed? Possible values: "top", "bottom", "right", "left", "auto", "auto top", "auto bottom", "auto right" and "auto left". Default to "bottom".
* @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file.
*/
public String getTooltipPosition() {
return (String) getStateHelper().eval(PropertyKeys.tooltipPosition);
}
/**
* Where is the tooltip to be displayed? Possible values: "top", "bottom", "right", "left", "auto", "auto top", "auto bottom", "auto right" and "auto left". Default to "bottom".
* Usually this method is called internally by the JSF engine.
*/
public void setTooltipPosition(String _tooltipPosition) {
getStateHelper().put(PropertyKeys.tooltipPosition, _tooltipPosition);
}
/**
* 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);
}
}