/* * Licensed Materials - Property of Perforce Software, Inc. * © Copyright Perforce Software, Inc. 2014, 2021 * © Copyright IBM Corp. 2009, 2014 * © Copyright ILOG 1996, 2009 * All Rights Reserved. * * Note to U.S. Government Users Restricted Rights: * The Software and Documentation were developed at private expense and * are "Commercial Items" as that term is defined at 48 CFR 2.101, * consisting of "Commercial Computer Software" and * "Commercial Computer Software Documentation", as such terms are * used in 48 CFR 12.212 or 48 CFR 227.7202-1 through 227.7202-4, * as applicable. */ package demo; import javax.faces.component.UIComponent; /** * This tag can be used to bind a javascript variable to some JSP property. */ SuppressWarnings("deprecation") public class JavaScriptVariableTag extends javax.faces.webapp.UIComponentTag { private String var; private String value; /** * Return the javascript variable value. * * @return the javascript variable value. */ public String getValue() { return value; } /** * Sets the javascript variable value. * * @param value * the javascript variable value to set. */ public void setValue(String value) { this.value = value; } /** * Return the javascript variable name. * * @return the javascript variable name. */ public String getVar() { return var; } /** * Sets the javascript variable name. * * @param var * the javascript variable name to set. */ public void setVar(String var) { this.var = var; } Override public String getComponentType() { return JavaScriptVariableComponent.class.getName(); } Override public String getRendererType() { return JavaScriptVariableRenderer.class.getName(); } Override protected void setProperties(UIComponent component) { super.setProperties(component); component.getAttributes().put(JavaScriptVariableComponent.VARNAME_PROPERTY, getVar()); if (getVar() != null && isValueReference(getVar())) { component.setValueBinding(JavaScriptVariableComponent.VARNAME_PROPERTY, getFacesContext().getApplication().createValueBinding(getVar())); } else { component.getAttributes().put(JavaScriptVariableComponent.VARNAME_PROPERTY, getVar()); } if (getValue() != null && isValueReference(getValue())) { component.setValueBinding(JavaScriptVariableComponent.VARVALUE_PROPERTY, getFacesContext().getApplication().createValueBinding(getValue())); } else { component.getAttributes().put(JavaScriptVariableComponent.VARVALUE_PROPERTY, getValue()); } } }