luehe 2002/08/21 10:05:52
Modified: jasper2/src/share/org/apache/jasper
JspCompilationContext.java
jasper2/src/share/org/apache/jasper/compiler
TagFileProcessor.java Validator.java
jasper2/src/share/org/apache/jasper/resources
messages.properties messages_es.properties
messages_ja.properties
jasper2/src/share/org/apache/jasper/servlet
JspServletWrapper.java
Log:
Implemented requirement that one <jsp:param> element must be present
for each variable declared using the variable directive that has a
'fragment' attribute equal to the name of the fragment being invoked.
Revision Changes Path
1.18 +11 -4 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspCompilationContext.java
Index: JspCompilationContext.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspCompilationContext.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- JspCompilationContext.java 20 Aug 2002 23:35:30 -0000 1.17
+++ JspCompilationContext.java 21 Aug 2002 17:05:52 -0000 1.18
@@ -66,7 +66,7 @@
import java.util.*;
import javax.servlet.ServletContext;
import javax.servlet.jsp.tagext.TagInfo;
-
+import javax.servlet.jsp.tagext.TagData;
import org.apache.jasper.compiler.JspRuntimeContext;
import org.apache.jasper.compiler.JspReader;
import org.apache.jasper.compiler.ServletWriter;
@@ -123,6 +123,7 @@
protected boolean isTagFile;
protected TagInfo tagInfo;
+ protected TagData tagData;
// jspURI _must_ be relative to the context
public JspCompilationContext(String jspUri,
@@ -157,6 +158,7 @@
public JspCompilationContext(String tagfile,
TagInfo tagInfo,
+ TagData tagData,
Options options,
ServletContext context,
JspServletWrapper jsw,
@@ -166,6 +168,7 @@
this(tagfile, false, options, context, jsw, rctxt);
this.isTagFile = true;
this.tagInfo = tagInfo;
+ this.tagData = tagData;
this.tagFileJars = tagFileJars;
if (tagFileJars != null && tagFileJars.get(tagfile) != null) {
isPackagedTagFile = true;
@@ -357,6 +360,10 @@
public TagInfo getTagInfo() {
return tagInfo;
+ }
+
+ public TagData getTagData() {
+ return tagData;
}
/**
1.16 +7 -4 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagFileProcessor.java
Index: TagFileProcessor.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagFileProcessor.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- TagFileProcessor.java 20 Aug 2002 23:35:30 -0000 1.15
+++ TagFileProcessor.java 21 Aug 2002 17:05:52 -0000 1.16
@@ -333,7 +333,8 @@
* Compiles and loads a tagfile.
*/
public static Class loadTagFile(JspCompilationContext ctxt,
- String tagFilePath, TagInfo tagInfo)
+ String tagFilePath, TagInfo tagInfo,
+ TagData tagData)
throws JasperException {
JspRuntimeContext rctxt = ctxt.getRuntimeContext();
@@ -347,6 +348,7 @@
ctxt.getOptions(),
tagFilePath,
tagInfo,
+ tagData,
ctxt.getRuntimeContext(),
ctxt.getTagFileJars());
}
@@ -372,7 +374,8 @@
TagFileInfo tagFileInfo = n.getTagFileInfo();
if (tagFileInfo != null) {
String tagFilePath = tagFileInfo.getPath();
- Class c = loadTagFile(ctxt, tagFilePath, n.getTagInfo());
+ Class c = loadTagFile(ctxt, tagFilePath, n.getTagInfo(),
+ n.getTagData());
n.setTagHandlerClass(c);
}
}
1.25 +57 -15 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Validator.java
Index: Validator.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Validator.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- Validator.java 21 Aug 2002 16:21:56 -0000 1.24
+++ Validator.java 21 Aug 2002 17:05:52 -0000 1.25
@@ -66,17 +66,9 @@
import java.util.HashMap;
import java.util.Enumeration;
+import javax.servlet.jsp.tagext.*;
import javax.servlet.jsp.el.FunctionMapper;
-import javax.servlet.jsp.tagext.FunctionInfo;
-import javax.servlet.jsp.tagext.PageData;
-import javax.servlet.jsp.tagext.JspFragment;
-import javax.servlet.jsp.tagext.TagData;
-import javax.servlet.jsp.tagext.TagInfo;
-import javax.servlet.jsp.tagext.TagAttributeInfo;
-import javax.servlet.jsp.tagext.TagLibraryInfo;
-import javax.servlet.jsp.tagext.ValidationMessage;
-
import org.apache.jasper.Constants;
import org.apache.jasper.JasperException;
@@ -303,10 +295,10 @@
private PageInfo pageInfo;
private ErrorDispatcher err;
+ private TagInfo tagInfo;
+ private TagData tagData;
- /**
- * A FunctionMapper, used to validate EL expressions.
- */
+ // A FunctionMapper, used to validate EL expressions.
private FunctionMapper functionMapper;
private static final JspUtil.ValidAttribute[] jspRootAttrs = {
@@ -387,6 +379,8 @@
ValidateVisitor(Compiler compiler) {
this.pageInfo = compiler.getPageInfo();
this.err = compiler.getErrorDispatcher();
+ this.tagInfo = compiler.getCompilationContext().getTagInfo();
+ this.tagData = compiler.getCompilationContext().getTagData();
this.functionMapper = new ValidatorFunctionMapper( this.pageInfo,
this.err );
}
@@ -853,11 +847,59 @@
}
public void visit(Node.InvokeAction n) throws JasperException {
+
JspUtil.checkAttributes("Invoke", n, invokeAttrs, err);
if (n.getAttributeValue("var") != null
&& n.getAttributeValue("varReader") != null) {
err.jspError(n, "jsp.error.invoke.varAndVarReader");
}
+
+ Node.Nodes subelements = n.getBody();
+ if (subelements != null) {
+ for (int i=0; i<subelements.size(); i++) {
+ Node subelem = subelements.getNode(i);
+ if (!(subelem instanceof Node.ParamAction)) {
+ err.jspError(n, "jsp.error.invoke.invalidBodyContent");
+ }
+ }
+ }
+
+ /*
+ * One <jsp:param> element must be present for each variable
+ * declared using the variable directive that has a 'fragment'
+ * attribute equal to the name of the fragment being invoked.
+ */
+ TagVariableInfo[] tagVars = tagInfo.getTagVariableInfos();
+ if (tagVars != null) {
+ String frag = n.getAttributeValue("fragment");
+ for (int i=0; i<tagVars.length; i++) {
+ String varName = tagVars[i].getNameGiven();
+ if (varName == null) {
+ varName = tagData.getAttributeString(
+ tagVars[i].getNameFromAttribute());
+ }
+ String tagVarFrag = tagVars[i].getFragment();
+ if (tagVarFrag == null || !tagVarFrag.equals(frag))
+ continue;
+ if (subelements == null) {
+ err.jspError(n, "jsp.error.invoke.missingParam",
+ varName);
+ }
+ boolean found = false;
+ for (int j=0; j<subelements.size() && !found; j++) {
+ Node subelem = subelements.getNode(j);
+ String paramName = subelem.getAttributeValue("name");
+ if (varName.equals(paramName)) {
+ found = true;
+ }
+ }
+ if (!found) {
+ err.jspError(n, "jsp.error.invoke.missingParam",
+ varName);
+ }
+ }
+ }
+
visitBody(n);
}
1.28 +3 -1 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/resources/messages.properties
Index: messages.properties
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/resources/messages.properties,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- messages.properties 21 Aug 2002 16:21:56 -0000 1.27
+++ messages.properties 21 Aug 2002 17:05:52 -0000 1.28
@@ -288,6 +288,8 @@
jsp.error.fragmentwithrtexprvalue=Cannot specify both 'fragment' and 'rtexprvalue' attributes.
If 'fragment' is present, 'rtexprvalue' is fixed as 'true'
jsp.error.fragmentWithDeclareOrScope=Both 'fragment' and 'declare' or 'scope' attributes
specified in variable directive
jsp.error.invoke.varAndVarReader=Both 'var' and 'varReader' specified in jsp:invoke
+jsp.error.invoke.invalidBodyContent=jsp:invoke contains body content other than whitespace
and jsp:param subelements
+jsp.error.invoke.missingParam=Missing jsp:param subelement for variable {0}
jsp.error.doBody.varAndVarReader=Both 'var' and 'varReader' specified in jsp:doBody
jsp.warning.bad.urlpattern.propertygroup=Bad value {0} in the url-pattern subelement in
web.xml
jsp.error.unknown_attribute_type=Unknown attribute type ({1}) for attribute {0}.
1.8 +3 -1 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/resources/messages_es.properties
Index: messages_es.properties
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/resources/messages_es.properties,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- messages_es.properties 20 Aug 2002 23:44:29 -0000 1.7
+++ messages_es.properties 21 Aug 2002 17:05:52 -0000 1.8
@@ -215,3 +215,5 @@
jsp.error.invoke.varAndVarReader=
jsp.error.doBody.varAndVarReader=
jsp.warning.bad.urlpattern.propertygroup=
+jsp.error.invoke.invalidBodyContent=
+jsp.error.invoke.missingParam=
1.7 +3 -1 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/resources/messages_ja.properties
Index: messages_ja.properties
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/resources/messages_ja.properties,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- messages_ja.properties 20 Aug 2002 23:44:29 -0000 1.6
+++ messages_ja.properties 21 Aug 2002 17:05:52 -0000 1.7
@@ -247,3 +247,5 @@
jsp.error.invoke.varAndVarReader=
jsp.error.doBody.varAndVarReader=
jsp.warning.bad.urlpattern.propertygroup=
+jsp.error.invoke.invalidBodyContent=
+jsp.error.invoke.missingParam=
1.14 +14 -13 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet/JspServletWrapper.java
Index: JspServletWrapper.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet/JspServletWrapper.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- JspServletWrapper.java 20 Aug 2002 23:35:30 -0000 1.13
+++ JspServletWrapper.java 21 Aug 2002 17:05:52 -0000 1.14
@@ -59,6 +59,13 @@
package org.apache.jasper.servlet;
+import java.io.IOException;
+import java.io.FileNotFoundException;
+import java.util.Hashtable;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.MalformedURLException;
+
import javax.servlet.Servlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletConfig;
@@ -69,13 +76,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.tagext.TagInfo;
-
-import java.io.IOException;
-import java.io.FileNotFoundException;
-import java.util.Hashtable;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.net.MalformedURLException;
+import javax.servlet.jsp.tagext.TagData;
import org.apache.jasper.JasperException;
import org.apache.jasper.Constants;
@@ -83,7 +84,6 @@
import org.apache.jasper.JspCompilationContext;
import org.apache.jasper.compiler.JspRuntimeContext;
import org.apache.jasper.runtime.HttpJspBase;
-
import org.apache.jasper.logging.Logger;
/**
@@ -135,13 +135,14 @@
*/
public JspServletWrapper(ServletContext servletContext, Options options,
String tagFilePath, TagInfo tagInfo,
- JspRuntimeContext rctxt, Hashtable tagFileJars)
+ TagData tagData, JspRuntimeContext rctxt,
+ Hashtable tagFileJars)
throws JasperException {
this.config = null; // not used
this.options = options;
this.jspUri = tagFilePath;
- ctxt = new JspCompilationContext(jspUri, tagInfo, options,
+ ctxt = new JspCompilationContext(jspUri, tagInfo, tagData, options,
servletContext, this, rctxt,
tagFileJars);
--
To unsubscribe, e-mail: <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>
|