001: /*
002: * Copyright 2006 The Apache Software Foundation.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package javax.faces.webapp;
017:
018: import javax.el.ValueExpression;
019: import javax.faces.application.Application;
020: import javax.faces.component.UIComponent;
021: import javax.faces.context.FacesContext;
022: import javax.servlet.jsp.JspException;
023: import javax.servlet.jsp.tagext.Tag;
024:
025: /**
026: * Base class for all JSP tags that represent a JSF UIComponent.
027: * <p>
028: * <i>Disclaimer</i>: The official definition for the behaviour of
029: * this class is the JSF specification but for legal reasons the
030: * specification cannot be replicated here. Any javadoc present on this
031: * class therefore describes the current implementation rather than the
032: * officially required behaviour, though it is believed that this class
033: * does comply with the specification.
034: *
035: * see Javadoc of <a href="http://java.sun.com/j2ee/javaserverfaces/1.2/docs/api/index.html">JSF Specification</a> for more.
036: *
037: * @author Bruno Aranda (latest modification by $Author: mbr $)
038: * @author Manfred Geiler
039: * @version $Revision: 513460 $ $Date: 2007-03-01 20:34:37 +0100 (Do, 01 Mrz 2007) $
040: *
041: * @since 1.2
042: */
043: public abstract class UIComponentELTag extends
044: UIComponentClassicTagBase implements Tag {
045:
046: private ValueExpression _binding = null;
047: private ValueExpression _rendered = null;
048:
049: public UIComponentELTag() {
050:
051: }
052:
053: public void release() {
054: super .release();
055: _binding = null;
056: _rendered = null;
057: }
058:
059: protected void setProperties(UIComponent component) {
060: if (getRendererType() != null) {
061: component.setRendererType(getRendererType());
062: }
063:
064: if (_rendered != null) {
065: if (_rendered.isLiteralText()) {
066: boolean b = Boolean.valueOf(
067: _rendered.getExpressionString()).booleanValue();
068: component.setRendered(b);
069: } else {
070: component.setValueExpression("rendered", _rendered);
071: }
072: }
073: }
074:
075: protected UIComponent createComponent(FacesContext context,
076: String newId) throws JspException {
077: UIComponent component;
078: Application application = context.getApplication();
079:
080: if (_binding != null) {
081: component = application.createComponent(_binding, context,
082: getComponentType());
083: component.setValueExpression("binding", _binding);
084: } else {
085: component = application.createComponent(getComponentType());
086: }
087:
088: component.setId(newId);
089: setProperties(component);
090:
091: return component;
092: }
093:
094: public void setBinding(ValueExpression binding) throws JspException {
095: _binding = binding;
096: }
097:
098: protected boolean hasBinding() {
099: return _binding != null;
100: }
101:
102: public void setRendered(ValueExpression rendered) {
103: _rendered = rendered;
104: }
105: }
|