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.commons.logging.Log; 021 import org.apache.commons.logging.LogFactory; 022 import org.apache.myfaces.tobago.apt.annotation.BodyContent; 023 import org.apache.myfaces.tobago.apt.annotation.Tag; 024 import org.apache.myfaces.tobago.context.ResourceManagerFactory; 025 import org.apache.myfaces.tobago.taglib.decl.HasId; 026 import org.apache.myfaces.tobago.taglib.decl.HasStringValue; 027 028 import javax.faces.context.FacesContext; 029 import javax.faces.el.ValueBinding; 030 import javax.faces.webapp.UIComponentTag; 031 import javax.servlet.jsp.JspException; 032 import javax.servlet.jsp.tagext.TagSupport; 033 034 @Tag(name = "include", bodyContent = BodyContent.EMPTY) 035 @Deprecated() 036 public class IncludeTag extends TagSupport implements HasId, HasStringValue { 037 038 private static final Log LOG = LogFactory.getLog(IncludeTag.class); 039 040 private String value; 041 042 043 public int doStartTag() throws JspException { 044 String pageName = null; 045 try { 046 FacesContext facesContext = FacesContext.getCurrentInstance(); 047 if (UIComponentTag.isValueReference(value)) { 048 ValueBinding valueBinding 049 = facesContext.getApplication().createValueBinding(value); 050 pageName = (String) valueBinding.getValue(facesContext); 051 } else { 052 pageName = value; 053 } 054 055 pageName = ResourceManagerFactory.getResourceManager(facesContext) 056 .getJsp(facesContext.getViewRoot(), pageName); 057 058 if (LOG.isDebugEnabled()) { 059 LOG.debug("include start pageName = '" + pageName + "'"); 060 } 061 pageContext.include(pageName); 062 if (LOG.isDebugEnabled()) { 063 LOG.debug("include end pageName = '" + pageName + "'"); 064 } 065 } catch (Throwable e) { 066 LOG.error("pageName = '" + pageName + "' " + e, e); 067 throw new JspException(e); 068 } 069 return super.doStartTag(); 070 } 071 072 public void release() { 073 value = null; 074 super.release(); 075 } 076 077 078 public String getValue() { 079 return value; 080 } 081 082 public void setValue(String value) { 083 this.value = value; 084 } 085 } 086