Listing 1. The component class manages the properties that represent the component’s state. We chose an appropriate base class for the component, based on its behavior. In this case, the component extends javax.faces.component.UIOutput to display a URL pointing to a style sheet file or the contents of an inline style sheet.

import javax.faces.component.*;
public class CSSComponent extends UIOutput {
        private Boolean link; 
        public String getFamily() { 
                return "faces.CSSFamily"; 
        } 
        public boolean isLink() { 
                if (link != null) 
                        return link.booleanValue(); 
                        ValueBinding vb = getValueBinding("link"); 
        if (vb != null) { 
                Boolean bvb = (Boolean) vb.getValue(
                        FacesContext.getCurrentInstance()); 
                if (bvb != null) 
                        return bvb.booleanValue(); 
        } 
        return false; 
        } 
        public void setLink(boolean link) { 
                this.link = new Boolean(link); 
        } 
        public Object saveState(FacesContext context) { 
                return new Object[] { super.saveState(context), 
                        link }; 
        } 
        public void restoreState(FacesContext context, 
                                                                                                        Object stateObj) { 
                Object[] state = (Object[]) stateObj; 
                super.restoreState(context, state[0]); 
                link = (Boolean) state[1]; 
        } 
}