Skip to main content

Temperature SPOT - Part 5

Posted by mriem on August 27, 2007 at 11:00 PM EDT

Getting the JSP part working requires a taglibrary. And its implementation. The code below describes that implementation.

package com.manorrock.jsf.sunspot.temperature;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
import javax.faces.webapp.UIComponentTag;

/**
 * A temperature tag for the SunSPOT.
 *
 * @author Manfred Riem (mriem@manorrock.com)
 */
public class TemperatureTag extends UIComponentTag {
    /**
     * Stores the component type.
     */
    private static String COMPONENT_TYPE = "com.manorrock.jsf.sunspot.temperature.TemperatureComponent";
    
    /**
     * Stores the renderer type.
     */
    private static String RENDERER_TYPE = "com.manorrock.jsf.sunspot.temperature.TemperatureRenderer";

    /**
     * Stores the SunSPOT id.
     */
    private String sunspotId;
    
    /**
     * Get the component type.
     */
    public String getComponentType() {
        return COMPONENT_TYPE;
    }

    /**
     * Get the renderer type.
     */
    public String getRendererType() {
        return RENDERER_TYPE;
    }
    
    /**
     * Set the SunSPOT id.
     */
    public void setSunspotId(String sunspotId) {
        this.sunspotId = sunspotId;
    }

    /**
     * Set the properties.
     *
     * @param component the component.
     */
    protected void setProperties(UIComponent component) {
        super.setProperties(component);

        if (sunspotId != null) {
            if (isValueReference(sunspotId)) {
                ValueBinding vb = FacesContext.getCurrentInstance().
                        getApplication().createValueBinding(sunspotId);
                component.setValueBinding("sunspotId", vb);
            } else {
                component.getAttributes().put("sunspotId", sunspotId);
            }
        }
    }
}
Related Topics >>