001    package org.apache.myfaces.tobago.taglib.component;
002    
003    /*
004     * Licensed to the Apache Software Foundation (ASF) under one or more
005     * contributor license agreements.  See the NOTICE file distributed with
006     * this work for additional information regarding copyright ownership.
007     * The ASF licenses this file to You under the Apache License, Version 2.0
008     * (the "License"); you may not use this file except in compliance with
009     * the License.  You may obtain a copy of the License at
010     *
011     *      http://www.apache.org/licenses/LICENSE-2.0
012     *
013     * Unless required by applicable law or agreed to in writing, software
014     * distributed under the License is distributed on an "AS IS" BASIS,
015     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016     * See the License for the specific language governing permissions and
017     * limitations under the License.
018     */
019    
020    /*
021     * Created on: 15.02.2002, 16:19:49
022     * $Id: BeanTag.java 636712 2008-03-13 11:14:02Z bommel $
023     */
024    
025    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_REQUIRED;
026    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_VALUE;
027    import org.apache.myfaces.tobago.component.ComponentUtil;
028    import org.apache.myfaces.tobago.internal.taglib.TagUtils;
029    
030    import javax.faces.component.UIComponent;
031    import javax.faces.component.ValueHolder;
032    
033    public abstract class BeanTag extends TobagoTag implements BeanTagDeclaration {
034    
035      private String converter;
036      private String value;
037      private String required;
038    
039      @Override
040      protected void setProperties(UIComponent component) {
041        super.setProperties(component);
042        if (component instanceof ValueHolder) {
043          ComponentUtil.setConverter((ValueHolder) component, converter);
044        }
045        TagUtils.setBooleanProperty(component, ATTR_REQUIRED, required);
046        TagUtils.setStringProperty(component, ATTR_VALUE, value);
047      }
048    
049      @Override
050      public void release() {
051        super.release();
052        this.converter = null;
053        this.value = null;
054        this.required = null;
055      }
056    
057      public String getConverter() {
058        return converter;
059      }
060    
061      public void setConverter(String converter) {
062        this.converter = converter;
063      }
064    
065      public String getValue() {
066        return value;
067      }
068    
069      public void setValue(String value) {
070        this.value = value;
071      }
072    
073      public String getRequired() {
074        return required;
075      }
076    
077      public void setRequired(String required) {
078        this.required = required;
079      }
080    }