01: /*
02: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
03: *
04: * This file is part of Resin(R) Open Source
05: *
06: * Each copy or derived work must preserve the copyright notice and this
07: * notice unmodified.
08: *
09: * Resin Open Source is free software; you can redistribute it and/or modify
10: * it under the terms of the GNU General Public License version 2
11: * as published by the Free Software Foundation.
12: *
13: * Resin Open Source 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, or any warranty
16: * of NON-INFRINGEMENT. See the GNU General Public License for more
17: * details.
18: *
19: * You should have received a copy of the GNU General Public License
20: * along with Resin Open Source; if not, write to the
21: *
22: * Free Software Foundation, Inc.
23: * 59 Temple Place, Suite 330
24: * Boston, MA 02111-1307 USA
25: *
26: * @author Scott Ferguson
27: */
28:
29: package javax.faces.webapp;
30:
31: import java.io.*;
32:
33: import javax.el.*;
34:
35: import javax.faces.application.*;
36: import javax.faces.component.*;
37: import javax.faces.context.*;
38:
39: import javax.servlet.jsp.*;
40: import javax.servlet.jsp.tagext.*;
41:
42: public abstract class UIComponentELTag extends
43: UIComponentClassicTagBase implements Tag {
44: private ValueExpression _binding;
45: private ValueExpression _rendered;
46:
47: public void setBinding(ValueExpression binding) throws JspException {
48: _binding = binding;
49: }
50:
51: protected boolean hasBinding() {
52: return _binding != null;
53: }
54:
55: public void setRendered(ValueExpression rendered) {
56: _rendered = rendered;
57: }
58:
59: protected ELContext getELContext() {
60: return getFacesContext().getELContext();
61: }
62:
63: protected void setProperties(UIComponent component) {
64: if (_binding != null)
65: component.setValueExpression("binding", _binding);
66:
67: if (_rendered != null)
68: component.setValueExpression("rendered", _rendered);
69:
70: String type = getRendererType();
71: if (type != null)
72: component.setRendererType(type);
73: }
74:
75: @Override
76: protected UIComponent createComponent(FacesContext context,
77: String newId) throws JspException {
78: Application app = context.getApplication();
79:
80: UIComponent component;
81:
82: if (_binding != null) {
83: component = app.createComponent(_binding, context,
84: getComponentType());
85: component.setValueExpression("binding", _binding);
86: } else
87: component = app.createComponent(getComponentType());
88:
89: component.setId(getId());
90:
91: setProperties(component);
92:
93: return component;
94: }
95: }
|