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