01: /******************************************************************************
02: * JBoss, a division of Red Hat *
03: * Copyright 2006, Red Hat Middleware, LLC, and individual *
04: * contributors as indicated by the @authors tag. See the *
05: * copyright.txt in the distribution for a full listing of *
06: * individual contributors. *
07: * *
08: * This is free software; you can redistribute it and/or modify it *
09: * under the terms of the GNU Lesser General Public License as *
10: * published by the Free Software Foundation; either version 2.1 of *
11: * the License, or (at your option) any later version. *
12: * *
13: * This software is distributed in the hope that it will be useful, *
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16: * Lesser General Public License for more details. *
17: * *
18: * You should have received a copy of the GNU Lesser General Public *
19: * License along with this software; if not, write to the Free *
20: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
21: * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
22: ******************************************************************************/package org.jboss.portal.faces.component.scroller;
23:
24: import javax.faces.application.Application;
25: import javax.faces.component.UIComponent;
26: import javax.faces.context.FacesContext;
27: import javax.faces.el.ValueBinding;
28: import javax.faces.webapp.UIComponentTag;
29:
30: /**
31: * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
32: * @version $Revision: 8784 $
33: */
34: public class ScrollerTag extends UIComponentTag {
35:
36: private String _for;
37: private String styleClass;
38:
39: public String getComponentType() {
40: return "com.jboss.portal.Scroller";
41: }
42:
43: public String getRendererType() {
44: return "default";
45: }
46:
47: public void setFor(String _for) {
48: this ._for = _for;
49: }
50:
51: public void setStyleClass(String styleClass) {
52: this .styleClass = styleClass;
53: }
54:
55: public void setProperties(UIComponent component) {
56: super .setProperties(component);
57: setString(component, "for", _for);
58: setString(component, "styleClass", styleClass);
59: }
60:
61: private void setString(UIComponent component, String attributeName,
62: String attributeValue) {
63: if (attributeValue == null) {
64: return;
65: }
66: if (isValueReference(attributeValue)) {
67: setValueBinding(component, attributeName, attributeValue);
68: } else {
69: component.getAttributes()
70: .put(attributeName, attributeValue);
71: }
72: }
73:
74: private void setValueBinding(UIComponent component,
75: String attributeName, String attributeValue) {
76: FacesContext facesContext = FacesContext.getCurrentInstance();
77: Application app = facesContext.getApplication();
78: ValueBinding vb = app.createValueBinding(attributeValue);
79: component.setValueBinding(attributeName, vb);
80: }
81:
82: public void release() {
83: super.release();
84: _for = null;
85: styleClass = null;
86: }
87: }
|