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