01: /*
02: * This file is part of the WfMOpen project.
03: * Copyright (C) 2001-2005 Danet GmbH (www.danet.de), BU BTS.
04: * All rights reserved.
05: *
06: * This program is free software; you can redistribute it and/or modify
07: * it under the terms of the GNU General Public License as published by
08: * the Free Software Foundation; either version 2 of the License, or
09: * (at your option) any later version.
10: *
11: * This program is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: * GNU General Public License for more details.
15: *
16: * You should have received a copy of the GNU General Public License
17: * along with this program; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: *
20: * $Id: HtmlLinkCssStylesheet.java,v 1.3 2007/03/27 21:59:43 mlipp Exp $
21: *
22: * $Log: HtmlLinkCssStylesheet.java,v $
23: * Revision 1.3 2007/03/27 21:59:43 mlipp
24: * Fixed lots of checkstyle warnings.
25: *
26: * Revision 1.2 2006/09/29 12:32:09 drmlipp
27: * Consistently using WfMOpen as projct name now.
28: *
29: * Revision 1.1 2006/09/14 13:34:11 drmlipp
30: * Component for linking stylesheet added.
31: *
32: */
33: package de.danet.an.util.jsf.taglib;
34:
35: import javax.faces.component.UIComponentBase;
36: import javax.faces.context.FacesContext;
37: import javax.faces.convert.Converter;
38: import javax.faces.el.ValueBinding;
39:
40: /**
41: * This class provides a component that causes a given CSS stylesheet
42: * to be included in the page.
43: *
44: * @author Michael Lipp
45: *
46: */
47: public class HtmlLinkCssStylesheet extends UIComponentBase {
48:
49: /** The component family. */
50: public static final String COMPONENT_FAMILY = "de.danet.bts.jsf.taglib";
51: /** The component type. */
52: public static final String COMPONENT_TYPE = "de.danet.bts.HtmlLinkCssStylesheet";
53:
54: private Object stylesheet;
55:
56: /* (non-Javadoc)
57: * @see javax.faces.component.UIComponent#getFamily()
58: */
59: public String getFamily() {
60: return COMPONENT_FAMILY;
61: }
62:
63: public void setStylesheet(Object value) {
64: stylesheet = (Object) value;
65: }
66:
67: public Object getStylesheet() {
68: if (stylesheet != null) {
69: return stylesheet;
70: }
71: ValueBinding vb = getValueBinding("stylesheet");
72: return vb != null ? (Object) vb.getValue(getFacesContext())
73: : null;
74: }
75:
76: public Object saveState(FacesContext context) {
77: Object[] values = new Object[2];
78: values[0] = super .saveState(context);
79: values[1] = stylesheet;
80: return ((Object) (values));
81: }
82:
83: public void restoreState(FacesContext context, Object state) {
84: Object[] values = (Object[]) state;
85: super .restoreState(context, values[0]);
86: stylesheet = (Object) values[1];
87: }
88: }
|