View | Details | Raw Unified | Return to bug 46339
Collapse All | Expand All

(-)trunk/impl/src/main/java/org/apache/jasper/compiler/Generator.java (-4 / +6 lines)
Lines 2100-2109 Link Here
2100
2100
2101
            n.setBeginJavaLine(out.getJavaLine());
2101
            n.setBeginJavaLine(out.getJavaLine());
2102
2102
2103
            // Copy virtual page scope of tag file to page scope of invoking
2104
            // page
2105
            out.printil(
2106
                "((org.apache.jasper.runtime.JspContextWrapper) this.jspContext).syncBeforeInvoke();");
2107
            String varReaderAttr = n.getTextAttribute("varReader");
2103
            String varReaderAttr = n.getTextAttribute("varReader");
2108
            String varAttr = n.getTextAttribute("var");
2104
            String varAttr = n.getTextAttribute("var");
2109
            if (varReaderAttr != null || varAttr != null) {
2105
            if (varReaderAttr != null || varAttr != null) {
Lines 2117-2122 Link Here
2117
            out.print(toGetterMethod(n.getTextAttribute("fragment")));
2113
            out.print(toGetterMethod(n.getTextAttribute("fragment")));
2118
            out.println(" != null) {");
2114
            out.println(" != null) {");
2119
            out.pushIndent();
2115
            out.pushIndent();
2116
            // Copy virtual page scope of tag file to page scope of invoking
2117
            // page
2118
            out.printin(
2119
                "((org.apache.jasper.runtime.JspContextWrapper) this.jspContext).syncBeforeInvoke(");
2120
            out.print(toGetterMethod(n.getTextAttribute("fragment")));
2121
            out.println(".getJspContext());");
2120
            out.printin(toGetterMethod(n.getTextAttribute("fragment")));
2122
            out.printin(toGetterMethod(n.getTextAttribute("fragment")));
2121
            out.println(".invoke(_jspx_sout);");
2123
            out.println(".invoke(_jspx_sout);");
2122
            out.popIndent();
2124
            out.popIndent();
(-)trunk/impl/src/main/java/org/apache/jasper/runtime/JspContextWrapper.java (-2 / +23 lines)
Lines 395-400 Link Here
395
    }
395
    }
396
396
397
    /**
397
    /**
398
     * Synchronize variables before fragment invokation
399
     * @param jspContext The JspContext the variable should sync to.  This
400
     *        is usually the context of the page where the fragment is. 
401
     */
402
    public void syncBeforeInvoke(JspContext jspContext) {
403
	copyTagToPageScope(VariableInfo.NESTED, (PageContext)jspContext);
404
	copyTagToPageScope(VariableInfo.AT_BEGIN, (PageContext)jspContext);
405
    }
406
407
    /**
398
     * Synchronize variables at end of tag file
408
     * Synchronize variables at end of tag file
399
     */
409
     */
400
    public void syncEndTagFile() {
410
    public void syncEndTagFile() {
Lines 410-415 Link Here
410
     * @param scope variable scope (one of NESTED, AT_BEGIN, or AT_END)
420
     * @param scope variable scope (one of NESTED, AT_BEGIN, or AT_END)
411
     */
421
     */
412
    private void copyTagToPageScope(int scope) {
422
    private void copyTagToPageScope(int scope) {
423
        copyTagToPageScope(scope,  invokingJspCtxt);
424
    }
425
426
    /**
427
     * Copies the variables of the given scope from the virtual page scope of
428
     * this JSP context wrapper to the page scope of the specified JSP context.
429
     *
430
     * @param scope variable scope (one of NESTED, AT_BEGIN, or AT_END)
431
     * @param jspContext the target context
432
     */
433
    private void copyTagToPageScope(int scope, PageContext jspContext) {
413
	Iterator iter = null;
434
	Iterator iter = null;
414
435
415
	switch (scope) {
436
	switch (scope) {
Lines 435-443 Link Here
435
	    Object obj = getAttribute(varName);
456
	    Object obj = getAttribute(varName);
436
	    varName = findAlias(varName);
457
	    varName = findAlias(varName);
437
	    if (obj != null) {
458
	    if (obj != null) {
438
		invokingJspCtxt.setAttribute(varName, obj);
459
		jspContext.setAttribute(varName, obj);
439
	    } else {
460
	    } else {
440
		invokingJspCtxt.removeAttribute(varName, PAGE_SCOPE);
461
		jspContext.removeAttribute(varName, PAGE_SCOPE);
441
	    }
462
	    }
442
	}
463
	}
443
    }
464
    }

Return to bug 46339