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    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_FOR;
021    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_GLOBAL_ONLY;
022    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_SUMMARY;
023    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_DETAIL;
024    import org.apache.myfaces.tobago.component.ComponentUtil;
025    
026    import javax.faces.component.UIComponent;
027    import javax.faces.component.UIMessages;
028    
029    
030    public class MessagesTag extends TobagoTag
031        implements MessagesTagDeclaration {
032    
033      private String forComponent;
034      private String showSummary;
035      private String showDetail;
036    
037      private String globalOnly;
038    
039      public String getComponentType() {
040        return UIMessages.COMPONENT_TYPE;
041      }
042    
043      protected void setProperties(UIComponent component) {
044        super.setProperties(component);
045        ComponentUtil.setStringProperty(component, ATTR_FOR, forComponent);
046        ComponentUtil.setBooleanProperty(component, ATTR_GLOBAL_ONLY, globalOnly);
047        ComponentUtil.setBooleanProperty(component, ATTR_SHOW_SUMMARY, showSummary);
048        ComponentUtil.setBooleanProperty(component, ATTR_SHOW_DETAIL, showDetail);
049      }
050    
051      public void release() {
052        super.release();
053        forComponent = null;
054        showSummary = null;
055        showDetail = null;
056      }
057    
058      public String getFor() {
059        return forComponent;
060      }
061    
062      public void setFor(String forComponent) {
063        this.forComponent = forComponent;
064      }
065    
066      public void setGlobalOnly(String globalOnly) {
067        this.globalOnly = globalOnly;
068      }
069    
070      public void setShowSummary(String showSummary) {
071        this.showSummary = showSummary;
072      }
073    
074      public void setShowDetail(String showDetail) {
075        this.showDetail = showDetail;
076      }
077    }