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 = "loose"; 040 041 // TODO move to renderkit 042 private String method = "POST"; 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 doctype = "loose"; 065 return result; 066 } 067 068 public String getComponentType() { 069 return UIPage.COMPONENT_TYPE; 070 } 071 072 public void release() { 073 super.release(); 074 doctype = "loose"; 075 method = "POST"; 076 state = null; 077 focusId = null; 078 label = null; 079 width = null; 080 height = null; 081 applicationIcon = null; 082 } 083 084 protected void setProperties(UIComponent component) { 085 super.setProperties(component); 086 ComponentUtil.setStringProperty(component, ATTR_METHOD, method); 087 ComponentUtil.setStringProperty(component, ATTR_DOCTYPE, doctype); 088 ComponentUtil.setStringProperty(component, ATTR_FOCUS_ID, focusId); 089 ComponentUtil.setStringProperty(component, ATTR_LABEL, label); 090 ComponentUtil.setValueBinding(component, ATTR_STATE, state); 091 ComponentUtil.setIntegerSizeProperty(component, ATTR_WIDTH, width); 092 ComponentUtil.setIntegerSizeProperty(component, ATTR_HEIGHT, height); 093 ComponentUtil.setStringProperty(component, ATTR_APPLICATION_ICON, applicationIcon); 094 } 095 096 public void setDoctype(String doctype) { 097 this.doctype = doctype; 098 } 099 100 public void setMethod(String method) { 101 this.method = method; 102 } 103 104 public void setState(String state) { 105 this.state = state; 106 } 107 108 public String getFocusId() { 109 return focusId; 110 } 111 112 public void setFocusId(String focusId) { 113 this.focusId = focusId; 114 } 115 116 public String getLabel() { 117 return label; 118 } 119 120 public void setLabel(String label) { 121 this.label = label; 122 } 123 124 public String getWidth() { 125 return width; 126 } 127 128 public void setWidth(String width) { 129 this.width = width; 130 } 131 132 public String getHeight() { 133 return height; 134 } 135 136 public void setHeight(String height) { 137 this.height = height; 138 } 139 140 public void setApplicationIcon(String icon) { 141 applicationIcon = icon; 142 } 143 144 public String getApplicationIcon() { 145 return applicationIcon; 146 } 147 } 148