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 org.apache.myfaces.tobago.component.ComponentUtil;
021    import org.apache.myfaces.tobago.component.UIPage;
022    import org.apache.myfaces.tobago.util.Deprecation;
023    
024    import javax.faces.component.UIComponent;
025    import javax.servlet.jsp.JspException;
026    import javax.servlet.jsp.tagext.BodyTag;
027    
028    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_APPLICATION_ICON;
029    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_DOCTYPE;
030    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_FOCUS_ID;
031    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_HEIGHT;
032    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LABEL;
033    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_METHOD;
034    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STATE;
035    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_WIDTH;
036    
037    // Some Weblogic versions need explicit 'implements' for BodyTag
038    public class PageTag extends TobagoBodyTag
039        implements BodyTag, PageTagDeclaration {
040    
041      @Deprecated
042      private String doctype;
043    
044      // TODO move to renderkit
045      private String method;
046    
047      private String state;
048    
049      private String focusId;
050    
051      private String label;
052    
053      private String width;
054    
055      private String height;
056    
057      private String applicationIcon;
058    
059      public int doEndTag() throws JspException {
060        UIPage page = (UIPage) getComponentInstance();
061        // TODO is this required?
062        // clear popups;
063        int result = super.doEndTag();
064        page.getPopups().clear();
065    
066        // reseting doctype and charset
067        return result;
068      }
069    
070      public String getComponentType() {
071        return UIPage.COMPONENT_TYPE;
072      }
073    
074      public void release() {
075        super.release();
076        doctype = null;
077        method = null;
078        state = null;
079        focusId = null;
080        label = null;
081        width = null;
082        height = null;
083        applicationIcon = null;
084      }
085    
086      protected void setProperties(UIComponent component) {
087        super.setProperties(component);
088        ComponentUtil.setStringProperty(component, ATTR_METHOD, method);
089        ComponentUtil.setStringProperty(component, ATTR_DOCTYPE, doctype);
090        ComponentUtil.setStringProperty(component, ATTR_FOCUS_ID, focusId);
091        ComponentUtil.setStringProperty(component, ATTR_LABEL, label);
092        ComponentUtil.setValueBinding(component, ATTR_STATE, state);
093        ComponentUtil.setIntegerSizeProperty(component, ATTR_WIDTH, width);
094        ComponentUtil.setIntegerSizeProperty(component, ATTR_HEIGHT, height);
095        ComponentUtil.setStringProperty(component, ATTR_APPLICATION_ICON, applicationIcon);
096      }
097    
098      public void setDoctype(String doctype) {
099        Deprecation.LOG.error("The attribute 'doctype' of 'UIPage' is deprecated. "
100            + "Please refer the documentation for further information.");
101        this.doctype = doctype;
102      }
103    
104      public void setMethod(String method) {
105        this.method = method;
106      }
107    
108      public void setState(String state) {
109        this.state = state;
110      }
111    
112      public String getFocusId() {
113        return focusId;
114      }
115    
116      public void setFocusId(String focusId) {
117        this.focusId = focusId;
118      }
119    
120      public String getLabel() {
121        return label;
122      }
123    
124      public void setLabel(String label) {
125        this.label = label;
126      }
127    
128      public String getWidth() {
129        return width;
130      }
131    
132      public void setWidth(String width) {
133        this.width = width;
134      }
135    
136      public String getHeight() {
137        return height;
138      }
139    
140      public void setHeight(String height) {
141        this.height = height;
142      }
143    
144      public void setApplicationIcon(String icon) {
145        applicationIcon = icon;
146      }
147    
148      public String getApplicationIcon() {
149        return applicationIcon;
150      }
151    }
152