001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019
020 package org.apache.myfaces.tobago.taglib.component;
021
022 import org.apache.myfaces.tobago.component.ComponentUtil;
023 import org.apache.myfaces.tobago.component.UIPage;
024 import org.apache.myfaces.tobago.util.Deprecation;
025
026 import javax.faces.component.UIComponent;
027 import javax.servlet.jsp.JspException;
028 import javax.servlet.jsp.tagext.BodyTag;
029
030 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_APPLICATION_ICON;
031 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_DOCTYPE;
032 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_FOCUS_ID;
033 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_HEIGHT;
034 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LABEL;
035 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_METHOD;
036 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STATE;
037 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_WIDTH;
038
039 // Some Weblogic versions need explicit 'implements' for BodyTag
040 public class PageTag extends TobagoBodyTag
041 implements BodyTag, PageTagDeclaration {
042
043 @Deprecated
044 private String doctype;
045
046 // TODO move to renderkit
047 private String method;
048
049 private String state;
050
051 private String focusId;
052
053 private String label;
054
055 private String width;
056
057 private String height;
058
059 private String applicationIcon;
060
061 public int doEndTag() throws JspException {
062 UIPage page = (UIPage) getComponentInstance();
063 // TODO is this required?
064 // clear popups;
065 int result = super.doEndTag();
066 page.getPopups().clear();
067
068 // reseting doctype and charset
069 return result;
070 }
071
072 public String getComponentType() {
073 return UIPage.COMPONENT_TYPE;
074 }
075
076 public void release() {
077 super.release();
078 doctype = null;
079 method = null;
080 state = null;
081 focusId = null;
082 label = null;
083 width = null;
084 height = null;
085 applicationIcon = null;
086 }
087
088 protected void setProperties(UIComponent component) {
089 super.setProperties(component);
090 ComponentUtil.setStringProperty(component, ATTR_METHOD, method);
091 ComponentUtil.setStringProperty(component, ATTR_DOCTYPE, doctype);
092 ComponentUtil.setStringProperty(component, ATTR_FOCUS_ID, focusId);
093 ComponentUtil.setStringProperty(component, ATTR_LABEL, label);
094 ComponentUtil.setValueBinding(component, ATTR_STATE, state);
095 ComponentUtil.setIntegerSizeProperty(component, ATTR_WIDTH, width);
096 ComponentUtil.setIntegerSizeProperty(component, ATTR_HEIGHT, height);
097 ComponentUtil.setStringProperty(component, ATTR_APPLICATION_ICON, applicationIcon);
098 }
099
100 public void setDoctype(String doctype) {
101 Deprecation.LOG.error("The attribute 'doctype' of 'UIPage' is deprecated. "
102 + "Please refer the documentation for further information.");
103 this.doctype = doctype;
104 }
105
106 public void setMethod(String method) {
107 this.method = method;
108 }
109
110 public void setState(String state) {
111 this.state = state;
112 }
113
114 public String getFocusId() {
115 return focusId;
116 }
117
118 public void setFocusId(String focusId) {
119 this.focusId = focusId;
120 }
121
122 public String getLabel() {
123 return label;
124 }
125
126 public void setLabel(String label) {
127 this.label = label;
128 }
129
130 public String getWidth() {
131 return width;
132 }
133
134 public void setWidth(String width) {
135 this.width = width;
136 }
137
138 public String getHeight() {
139 return height;
140 }
141
142 public void setHeight(String height) {
143 this.height = height;
144 }
145
146 public void setApplicationIcon(String icon) {
147 applicationIcon = icon;
148 }
149
150 public String getApplicationIcon() {
151 return applicationIcon;
152 }
153 }
154