1 /* 2 * $Id: ELInitDefinitionsTag.java 471754 2006-11-06 14:55:09Z husted $ 3 * 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 */ 21 package org.apache.strutsel.taglib.tiles; 22 23 import org.apache.struts.tiles.taglib.InitDefinitionsTag; 24 import org.apache.strutsel.taglib.utils.EvalHelper; 25 26 import javax.servlet.jsp.JspException; 27 28 /** 29 * Init definitions factory. <p> This class is a subclass of the class 30 * <code>org.apache.struts.taglib.tiles.InitDefinitionsTag</code> which 31 * provides most of the described functionality. This subclass allows all 32 * attribute values to be specified as expressions utilizing the JavaServer 33 * Pages Standard Library expression language. 34 * 35 * @version $Rev: 471754 $ 36 */ 37 public class ELInitDefinitionsTag extends InitDefinitionsTag { 38 /** 39 * Instance variable mapped to "file" tag attribute. (Mapping set in 40 * associated BeanInfo class.) 41 */ 42 private String fileExpr; 43 44 /** 45 * Instance variable mapped to "classname" tag attribute. (Mapping set in 46 * associated BeanInfo class.) 47 */ 48 private String classnameExpr; 49 50 /** 51 * Getter method for "file" tag attribute. (Mapping set in associated 52 * BeanInfo class.) 53 */ 54 public String getFileExpr() { 55 return (fileExpr); 56 } 57 58 /** 59 * Getter method for "classname" tag attribute. (Mapping set in associated 60 * BeanInfo class.) 61 */ 62 public String getClassnameExpr() { 63 return (classnameExpr); 64 } 65 66 /** 67 * Setter method for "file" tag attribute. (Mapping set in associated 68 * BeanInfo class.) 69 */ 70 public void setFileExpr(String fileExpr) { 71 this.fileExpr = fileExpr; 72 } 73 74 /** 75 * Setter method for "classname" tag attribute. (Mapping set in associated 76 * BeanInfo class.) 77 */ 78 public void setClassnameExpr(String classnameExpr) { 79 this.classnameExpr = classnameExpr; 80 } 81 82 /** 83 * Resets attribute values for tag reuse. 84 */ 85 public void release() { 86 super.release(); 87 setFileExpr(null); 88 setClassnameExpr(null); 89 } 90 91 /** 92 * Process the start tag. 93 * 94 * @throws JspException if a JSP exception has occurred 95 */ 96 public int doStartTag() throws JspException { 97 evaluateExpressions(); 98 99 return (super.doStartTag()); 100 } 101 102 /** 103 * Processes all attribute values which use the JSTL expression evaluation 104 * engine to determine their values. 105 * 106 * @throws JspException if a JSP exception has occurred 107 */ 108 private void evaluateExpressions() 109 throws JspException { 110 String string = null; 111 112 if ((string = 113 EvalHelper.evalString("file", getFileExpr(), this, pageContext)) != null) { 114 setFile(string); 115 } 116 117 if ((string = 118 EvalHelper.evalString("classname", getClassnameExpr(), this, 119 pageContext)) != null) { 120 setClassname(string); 121 } 122 } 123 }