View Javadoc

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one
    3    * or more contributor license agreements.  See the NOTICE file
    4    * distributed with this work for additional information
    5    * regarding copyright ownership.  The ASF licenses this file
    6    * to you under the Apache License, Version 2.0 (the
    7    * "License"); you may not use this file except in compliance
    8    * with the License.  You may obtain a copy of the License at
    9    *
    10   *   http://www.apache.org/licenses/LICENSE-2.0
    11   *
    12   * Unless required by applicable law or agreed to in writing,
    13   * software distributed under the License is distributed on an
    14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    15   * KIND, either express or implied.  See the License for the
    16   * specific language governing permissions and limitations
    17   * under the License.
    18   */
    19  package org.apache.myfaces.shared_orchestra.taglib;
    20
    21  import org.apache.myfaces.shared_orchestra.renderkit.JSFAttr;
    22
    23  import javax.faces.component.UIComponent;
    24  import javax.faces.webapp.UIComponentTag;
    25
    26  /**
    27   * @author Manfred Geiler (latest modification by $Author: grantsmith $)
    28   * @version $Revision: 472630 $ $Date: 2006-11-08 15:40:03 -0500 (Wed, 08 Nov 2006) $
    29   */
    30  public abstract class UIComponentTagBase
    31          extends UIComponentTag
    32  {
    33      //private static final Log log = LogFactory.getLog(UIComponentTagBase.class);
    34
    35      //UIComponent attributes
    36      private String _forceId;
    37      private String _forceIdIndex = "true";
    38      private String _javascriptLocation;
    39      private String _imageLocation;
    40      private String _styleLocation;
    41
    42      //Special UIComponent attributes (ValueHolder, ConvertibleValueHolder)
    43      private String _value;
    44      private String _converter;
    45      //attributes id, rendered and binding are handled by UIComponentTag
    46
    47      public void release() {
    48          super.release();
    49
    50          _forceId=null;
    51          //see declaration of that property
    52          _forceIdIndex = "true";
    53
    54          _value=null;
    55          _converter=null;
    56
    57          _javascriptLocation = null;
    58          _imageLocation = null;
    59          _styleLocation = null;
    60      }
    61
    62      protected void setProperties(UIComponent component)
    63      {
    64          super.setProperties(component);
    65
    66          setBooleanProperty(component, org.apache.myfaces.shared_orchestra.renderkit.JSFAttr.FORCE_ID_ATTR, _forceId);
    67          setBooleanProperty(component, org.apache.myfaces.shared_orchestra.renderkit.JSFAttr.FORCE_ID_INDEX_ATTR, _forceIdIndex);
    68          if (_javascriptLocation != null) setStringProperty(component, JSFAttr.JAVASCRIPT_LOCATION, _javascriptLocation);
    69          if (_imageLocation != null) setStringProperty(component, org.apache.myfaces.shared_orchestra.renderkit.JSFAttr.IMAGE_LOCATION, _imageLocation);
    70          if (_styleLocation != null) setStringProperty(component, JSFAttr.STYLE_LOCATION, _styleLocation);
    71
    72          //rendererType already handled by UIComponentTag
    73
    74          setValueProperty(component, _value);
    75          setConverterProperty(component, _converter);
    76      }
    77
    78      /**
    79       * Sets the forceId attribute of the tag.  NOTE: Not every tag that extends this class will
    80       * actually make use of this attribute.  Check the TLD to see which components actually
    81       * implement it.
    82       *
    83       * @param aForceId The value of the forceId attribute.
    84       */
    85      public void setForceId(String aForceId)
    86      {
    87          _forceId = aForceId;
    88      }
    89
    90      /**
    91       * Sets the forceIdIndex attribute of the tag.  NOTE: Not every tag that extends this class will
    92       * actually make use of this attribute.  Check the TLD to see which components actually implement it.
    93       *
    94       * @param aForceIdIndex The value of the forceIdIndex attribute.
    95       */
    96      public void setForceIdIndex(String aForceIdIndex)
    97      {
    98          _forceIdIndex = aForceIdIndex;
    99      }
    100
    101     public void setValue(String value)
    102     {
    103         _value = value;
    104     }
    105
    106     public void setConverter(String converter)
    107     {
    108         _converter = converter;
    109     }
    110
    111
    112     /**
    113      * Sets the javascript location attribute of the tag.  NOTE: Not every tag that extends this class will
    114      * actually make use of this attribute.  Check the TLD to see which components actually implement it.
    115      *
    116      * @param aJavascriptLocation The alternate javascript location to use.
    117      */
    118     public void setJavascriptLocation(String aJavascriptLocation)
    119     {
    120         _javascriptLocation = aJavascriptLocation;
    121     }
    122
    123     /**
    124      * Sets the image location attribute of the tag.  NOTE: Not every tag that extends this class will
    125      * actually make use of this attribute.  Check the TLD to see which components actually implement it.
    126      *
    127      * @param aImageLocation The alternate image location to use.
    128      */
    129     public void setImageLocation(String aImageLocation)
    130     {
    131         _imageLocation = aImageLocation;
    132     }
    133
    134     /**
    135      * Sets the style location attribute of the tag.  NOTE: Not every tag that extends this class will
    136      * actually make use of this attribute.  Check the TLD to see which components actually implement it.
    137      *
    138      * @param aStyleLocation The alternate style location to use.
    139      */
    140     public void setStyleLocation(String aStyleLocation)
    141     {
    142         _styleLocation = aStyleLocation;
    143     }
    144
    145     // sub class helpers
    146
    147     protected void setIntegerProperty(UIComponent component, String propName, String value)
    148     {
    149         UIComponentTagUtils.setIntegerProperty(getFacesContext(), component, propName, value);
    150     }
    151
    152     protected void setLongProperty(UIComponent component, String propName, String value)
    153     {
    154         UIComponentTagUtils.setLongProperty(getFacesContext(), component, propName, value);
    155     }
    156
    157     protected void setStringProperty(UIComponent component, String propName, String value)
    158     {
    159         UIComponentTagUtils.setStringProperty(getFacesContext(), component, propName, value);
    160     }
    161
    162     protected void setBooleanProperty(UIComponent component, String propName, String value)
    163     {
    164         UIComponentTagUtils.setBooleanProperty(getFacesContext(), component, propName, value);
    165     }
    166
    167     private void setValueProperty(UIComponent component, String value)
    168     {
    169         UIComponentTagUtils.setValueProperty(getFacesContext(), component, value);
    170     }
    171
    172     private void setConverterProperty(UIComponent component, String value)
    173     {
    174         UIComponentTagUtils.setConverterProperty(getFacesContext(), component, value);
    175     }
    176
    177     protected void setValidatorProperty(UIComponent component, String value)
    178     {
    179         UIComponentTagUtils.setValidatorProperty(getFacesContext(), component, value);
    180     }
    181
    182     protected void setActionProperty(UIComponent component, String action)
    183     {
    184         UIComponentTagUtils.setActionProperty(getFacesContext(), component, action);
    185     }
    186
    187     protected void setActionListenerProperty(UIComponent component, String actionListener)
    188     {
    189         UIComponentTagUtils.setActionListenerProperty(getFacesContext(), component, actionListener);
    190     }
    191
    192     protected void setValueChangedListenerProperty(UIComponent component, String valueChangedListener)
    193     {
    194         UIComponentTagUtils.setValueChangedListenerProperty(getFacesContext(), component, valueChangedListener);
    195     }
    196
    197     protected void setValueBinding(UIComponent component,
    198                                    String propName,
    199                                    String value)
    200     {
    201         UIComponentTagUtils.setValueBinding(getFacesContext(), component, propName, value);
    202     }
    203
    204
    205 }
    206