Author: remy.maucherat(a)jboss.com
Date: 2009-01-09 11:08:38 -0500 (Fri, 09 Jan 2009)
New Revision: 898
Modified:
trunk/java/org/apache/jasper/compiler/Generator.java
trunk/java/org/apache/jasper/runtime/JspContextWrapper.java
trunk/webapps/docs/changelog.xml
Log:
- Port Jasper patch.
Modified: trunk/java/org/apache/jasper/compiler/Generator.java
===================================================================
--- trunk/java/org/apache/jasper/compiler/Generator.java 2009-01-09 11:58:24 UTC (rev
897)
+++ trunk/java/org/apache/jasper/compiler/Generator.java 2009-01-09 16:08:38 UTC (rev
898)
@@ -2050,9 +2050,6 @@
n.setBeginJavaLine(out.getJavaLine());
- // Copy virtual page scope of tag file to page scope of invoking
- // page
- out.printil("((org.apache.jasper.runtime.JspContextWrapper)
this.jspContext).syncBeforeInvoke();");
String varReaderAttr = n.getTextAttribute("varReader");
String varAttr = n.getTextAttribute("var");
if (varReaderAttr != null || varAttr != null) {
@@ -2066,6 +2063,11 @@
out.print(toGetterMethod(n.getTextAttribute("fragment")));
out.println(" != null) {");
out.pushIndent();
+ // Copy virtual page scope of tag file to page scope of invoking
+ // page
+ out.printil("((org.apache.jasper.runtime.JspContextWrapper)
this.jspContext).syncBeforeInvoke(");
+ out.print(toGetterMethod(n.getTextAttribute("fragment")));
+ out.println(".getJspContext());");
out.printin(toGetterMethod(n.getTextAttribute("fragment")));
out.println(".invoke(_jspx_sout);");
out.popIndent();
Modified: trunk/java/org/apache/jasper/runtime/JspContextWrapper.java
===================================================================
--- trunk/java/org/apache/jasper/runtime/JspContextWrapper.java 2009-01-09 11:58:24 UTC
(rev 897)
+++ trunk/java/org/apache/jasper/runtime/JspContextWrapper.java 2009-01-09 16:08:38 UTC
(rev 898)
@@ -334,7 +334,17 @@
copyTagToPageScope(VariableInfo.AT_BEGIN);
}
- /**
+ /**
+ * Synchronize variables before fragment invokation
+ * @param jspContext The JspContext the variable should sync to. This
+ * is usually the context of the page where the fragment is.
+ */
+ public void syncBeforeInvoke(JspContext jspContext) {
+ copyTagToPageScope(VariableInfo.NESTED, (PageContext)jspContext);
+ copyTagToPageScope(VariableInfo.AT_BEGIN, (PageContext)jspContext);
+ }
+
+ /**
* Synchronize variables at end of tag file
*/
public void syncEndTagFile() {
@@ -351,6 +361,17 @@
* variable scope (one of NESTED, AT_BEGIN, or AT_END)
*/
private void copyTagToPageScope(int scope) {
+ copyTagToPageScope(scope, invokingJspCtxt);
+ }
+
+ /**
+ * Copies the variables of the given scope from the virtual page scope of
+ * this JSP context wrapper to the page scope of the specified JSP context.
+ *
+ * @param scope variable scope (one of NESTED, AT_BEGIN, or AT_END)
+ * @param jspContext the target context
+ */
+ private void copyTagToPageScope(int scope, PageContext jspContext) {
Iterator iter = null;
switch (scope) {
@@ -376,9 +397,9 @@
Object obj = getAttribute(varName);
varName = findAlias(varName);
if (obj != null) {
- invokingJspCtxt.setAttribute(varName, obj);
+ jspContext.setAttribute(varName, obj);
} else {
- invokingJspCtxt.removeAttribute(varName, PAGE_SCOPE);
+ jspContext.removeAttribute(varName, PAGE_SCOPE);
}
}
}
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2009-01-09 11:58:24 UTC (rev 897)
+++ trunk/webapps/docs/changelog.xml 2009-01-09 16:08:38 UTC (rev 898)
@@ -126,6 +126,9 @@
<bug>46471</bug>: Use jar url and tag file path to uniquely ID a tag
file to prevent naming
clashes. (markt)
</fix>
+ <fix>
+ <bug>46339</bug>: Fix variable sync problems for fragments. Submitted
by Kin-Man Chung. (markt)
+ </fix>
</changelog>
</subsection>
</section>
Show replies by date