| /* |
| * Copyright (c) 2004, 2018 Oracle and/or its affiliates. All rights reserved. |
| * |
| * This program and the accompanying materials are made available under the |
| * terms of the Eclipse Public License v. 2.0, which is available at |
| * http://www.eclipse.org/legal/epl-2.0. |
| * |
| * This Source Code may also be made available under the following Secondary |
| * Licenses when the conditions for such availability set forth in the |
| * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, |
| * version 2 with the GNU Classpath Exception, which is available at |
| * https://www.gnu.org/software/classpath/license.html. |
| * |
| * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 |
| */ |
| |
| package components.taglib; |
| |
| import components.components.ChartItemComponent; |
| import jakarta.faces.component.UIComponent; |
| import jakarta.faces.context.FacesContext; |
| |
| import jakarta.faces.el.ValueBinding; |
| import jakarta.faces.webapp.UIComponentTag; |
| |
| /** |
| * <p><strong>ChartItemTag</strong> is the tag handler that processes the |
| * <code>chartItem</code> custom tag.</p> |
| */ |
| |
| public class ChartItemTag extends UIComponentTag { |
| |
| public ChartItemTag() { |
| super(); |
| } |
| |
| // |
| // Class methods |
| // |
| |
| // |
| // Accessors |
| // |
| |
| /** |
| * <p>The label for this item</p> |
| */ |
| private String itemLabel = null; |
| /** |
| *<p>Set the label for this item. |
| */ |
| public void setItemLabel(String label) { |
| this.itemLabel = label; |
| } |
| |
| /** |
| * <p>The color for this item.</p> |
| */ |
| private String itemColor = null; |
| /** |
| *<p>Set the color for this item. |
| */ |
| public void setItemColor(String color) { |
| this.itemColor = color; |
| } |
| |
| /** |
| * <p>The value for this item.</p> |
| */ |
| private String itemValue = null; |
| /** |
| *<p>Set the ualue for this item. |
| */ |
| public void setItemValue(String itemVal) { |
| this.itemValue = itemVal; |
| } |
| |
| private String value = null; |
| public void setValue(String value) { |
| this.value = value; |
| } |
| |
| // |
| // General Methods |
| // |
| |
| /** |
| * <p>Return the type of the component. |
| */ |
| public String getComponentType() { |
| return "ChartItem"; |
| } |
| |
| /** |
| * <p>Return the renderer type (if any) |
| */ |
| public String getRendererType() { |
| return null; |
| } |
| |
| /** |
| * <p>Release any resources used by this tag handler |
| */ |
| public void release() { |
| super.release(); |
| itemLabel = null; |
| itemValue = null; |
| itemColor = null; |
| } |
| |
| // |
| // Methods from BaseComponentTag |
| // |
| |
| /** |
| * <p>Set the component properties |
| */ |
| protected void setProperties(UIComponent component) { |
| super.setProperties(component); |
| ChartItemComponent chartItem = (ChartItemComponent) component; |
| if (null != value) { |
| if (isValueReference(value)) { |
| ValueBinding vb = FacesContext.getCurrentInstance() |
| .getApplication().createValueBinding(value); |
| chartItem.setValueBinding("value", vb); |
| } else { |
| chartItem.setValue(value); |
| } |
| } |
| |
| if (null != itemLabel) { |
| if (isValueReference(itemLabel)) { |
| ValueBinding vb = FacesContext.getCurrentInstance() |
| .getApplication().createValueBinding(itemLabel); |
| chartItem.setValueBinding("itemLabel", vb); |
| } else { |
| chartItem.setItemLabel(itemLabel); |
| } |
| } |
| |
| if (null != itemColor) { |
| if (isValueReference(itemColor)) { |
| ValueBinding vb = FacesContext.getCurrentInstance() |
| .getApplication().createValueBinding(itemColor); |
| chartItem.setValueBinding("itemColor", vb); |
| } else { |
| chartItem.setItemColor(itemColor); |
| } |
| } |
| |
| if (null != itemValue) { |
| if (isValueReference(itemValue)) { |
| ValueBinding vb = FacesContext.getCurrentInstance() |
| .getApplication().createValueBinding(itemValue); |
| chartItem.setValueBinding("itemValue", vb); |
| } else { |
| chartItem.setItemValue(itemValue); |
| } |
| } |
| } |
| |
| } |