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) {
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();
}
/**
- * 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() {
* 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<String> iter = null;
switch (scope) {
Object obj = getAttribute(varName);
varName = findAlias(varName);
if (obj != null) {
- jspContext.setAttribute(varName, obj);
+ invokingJspCtxt.setAttribute(varName, obj);
} else {
- jspContext.removeAttribute(varName, PAGE_SCOPE);
+ invokingJspCtxt.removeAttribute(varName, PAGE_SCOPE);
}
}
}