javax.servlet.jsp.PageContext Java Examples

The following examples show how to use javax.servlet.jsp.PageContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MessageTagTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void messageWithVarAndScope() throws JspException {
	PageContext pc = createPageContext();
	MessageTag tag = new MessageTag();
	tag.setPageContext(pc);
	tag.setText("text & text");
	tag.setVar("testvar");
	tag.setScope("page");
	tag.doStartTag();
	assertEquals("Correct doEndTag return value", Tag.EVAL_PAGE, tag.doEndTag());
	assertEquals("text & text", pc.getAttribute("testvar"));
	tag.release();

	tag = new MessageTag();
	tag.setPageContext(pc);
	tag.setCode("test");
	tag.setVar("testvar2");
	tag.doStartTag();
	assertEquals("Correct doEndTag return value", Tag.EVAL_PAGE, tag.doEndTag());
	assertEquals("Correct message", "test message", pc.getAttribute("testvar2"));
	tag.release();
}
 
Example #2
Source File: JspRuntimeLibrary.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
public static void handleSetPropertyExpression(Object bean,
    String prop, String expression, PageContext pageContext,
    ProtectedFunctionMapper functionMapper )
    throws JasperException
{
    try {
        Method method = getWriteMethod(bean.getClass(), prop);
        method.invoke(bean, new Object[] {
            PageContextImpl.proprietaryEvaluate(
                expression,
                method.getParameterTypes()[0],
                pageContext,
                functionMapper)
        });
    } catch (Exception ex) {
        Throwable thr = ExceptionUtils.unwrapInvocationTargetException(ex);
        ExceptionUtils.handleThrowable(thr);
        throw new JasperException(ex);
    }
}
 
Example #3
Source File: FormTag.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Clears the stored {@link TagWriter}.
 */
@Override
public void doFinally() {
	super.doFinally();
	this.pageContext.removeAttribute(MODEL_ATTRIBUTE_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
	if (this.previousNestedPath != null) {
		// Expose previous nestedPath value.
		this.pageContext.setAttribute(NESTED_PATH_VARIABLE_NAME, this.previousNestedPath, PageContext.REQUEST_SCOPE);
	}
	else {
		// Remove exposed nestedPath value.
		this.pageContext.removeAttribute(NESTED_PATH_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
	}
	this.tagWriter = null;
	this.previousNestedPath = null;
}
 
Example #4
Source File: DumpTagTest.java    From logging-log4j2 with Apache License 2.0 6 votes vote down vote up
@Test
public void testDoEndTagSessionScope() throws Exception {
    this.context.setAttribute("otherAttribute03", "lostValue03", PageContext.PAGE_SCOPE);
    this.context.setAttribute("coolAttribute01", "weirdValue01", PageContext.SESSION_SCOPE);
    this.context.setAttribute("testAttribute02", "testValue02", PageContext.SESSION_SCOPE);

    this.tag.setScope("session");
    final int returnValue = this.tag.doEndTag();
    assertEquals("The return value is not correct.", Tag.EVAL_PAGE, returnValue);

    this.writer.flush();
    final String output = new String(this.output.toByteArray(), UTF8);
    assertEquals("The output is not correct.",
            "<dl>" +
                    "<dt><code>coolAttribute01</code></dt><dd><code>weirdValue01</code></dd>" +
                    "<dt><code>testAttribute02</code></dt><dd><code>testValue02</code></dd>" +
                    "</dl>", output);
}
 
Example #5
Source File: JspFactoryImpl.java    From packagedrone with Eclipse Public License 1.0 6 votes vote down vote up
public PageContext getPageContext(Servlet servlet,
			      ServletRequest request,
                                     ServletResponse response,
                                     String errorPageURL,                    
                                     boolean needsSession,
			      int bufferSize,
                                     boolean autoflush) {

if (Constants.IS_SECURITY_ENABLED) {
    PrivilegedGetPageContext dp =
                   new PrivilegedGetPageContext(
	        this, servlet, request, response, errorPageURL,
                       needsSession, bufferSize, autoflush);
    return AccessController.doPrivileged(dp);
} else {
    return internalGetPageContext(servlet, request, response,
				  errorPageURL, needsSession,
				  bufferSize, autoflush);
}
   }
 
Example #6
Source File: UnpagedListDisplayTagTest.java    From spacewalk with GNU General Public License v2.0 6 votes vote down vote up
public void setUp() throws Exception {
    super.setUp();
    setImposteriser(ClassImposteriser.INSTANCE);
    RhnBaseTestCase.disableLocalizationServiceLogging();

    request = mock(HttpServletRequest.class);
    response = mock(HttpServletResponse.class);
    context = mock(PageContext.class);
    writer = new RhnMockJspWriter();

    ldt = new UnpagedListDisplayTag();
    lt = new ListTag();
    ldt.setPageContext(context);
    ldt.setParent(lt);

    lt.setPageList(new DataResult(CSVWriterTest.getTestListOfMaps()));

    context().checking(new Expectations() { {
        atLeast(1).of(context).getOut();
        will(returnValue(writer));
        atLeast(1).of(context).getRequest();
        will(returnValue(request));
        atLeast(1).of(context).setAttribute("current", null);
    } });
}
 
Example #7
Source File: MessageTagTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void messageTagWithCodeAndArguments() throws JspException {
	PageContext pc = createPageContext();
	final StringBuffer message = new StringBuffer();
	MessageTag tag = new MessageTag() {
		@Override
		protected void writeMessage(String msg) {
			message.append(msg);
		}
	};
	tag.setPageContext(pc);
	tag.setCode("testArgs");
	tag.setArguments("arg1,arg2");
	assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
	assertEquals("Correct doEndTag return value", Tag.EVAL_PAGE, tag.doEndTag());
	assertEquals("Correct message", "test arg1 message arg2", message.toString());
}
 
Example #8
Source File: MessageTagTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void messageTagWithCodeAndArgumentAndNestedArgument() throws JspException {
	PageContext pc = createPageContext();
	final StringBuffer message = new StringBuffer();
	MessageTag tag = new MessageTag() {
		@Override
		protected void writeMessage(String msg) {
			message.append(msg);
		}
	};
	tag.setPageContext(pc);
	tag.setCode("testArgs");
	assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
	tag.setArguments(5);
	tag.addArgument(7);
	assertEquals("Correct doEndTag return value", Tag.EVAL_PAGE, tag.doEndTag());
	assertEquals("Correct message", "test 5 message 7", message.toString());
}
 
Example #9
Source File: MessageTagTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void messageTagWithCodeAndStringArgumentWithCustomSeparator() throws JspException {
	PageContext pc = createPageContext();
	final StringBuffer message = new StringBuffer();
	MessageTag tag = new MessageTag() {
		@Override
		protected void writeMessage(String msg) {
			message.append(msg);
		}
	};
	tag.setPageContext(pc);
	tag.setCode("testArgs");
	tag.setArguments("arg1,1;arg2,2");
	tag.setArgumentSeparator(";");
	assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
	assertEquals("Correct doEndTag return value", Tag.EVAL_PAGE, tag.doEndTag());
	assertEquals("Correct message", "test arg1,1 message arg2,2", message.toString());
}
 
Example #10
Source File: SetLoggerTagTest.java    From logging-log4j2 with Apache License 2.0 6 votes vote down vote up
@Test
public void testDoEndTagStringVarRequestScope() throws Exception {
    this.tag.setLogger("testDoEndTagStringVarRequestScope");

    this.tag.setVar("goodbyeCruelWorld");
    this.tag.setScope("request");

    assertNull("The default logger should be null.", TagUtils.getDefaultLogger(this.context));
    assertEquals("The return value is not correct.", Tag.EVAL_PAGE, this.tag.doEndTag());
    assertNull("The default logger should still be null.", TagUtils.getDefaultLogger(this.context));

    final Object attribute = this.context.getAttribute("goodbyeCruelWorld", PageContext.REQUEST_SCOPE);
    assertNotNull("The attribute should not be null.", attribute);
    assertTrue("The attribute should be a Log4jTaglibLogger.", attribute instanceof Log4jTaglibLogger);

    final Log4jTaglibLogger logger = (Log4jTaglibLogger)attribute;
    assertEquals("The logger name is not correct.", "testDoEndTagStringVarRequestScope", logger.getName());
}
 
Example #11
Source File: AccountingLineViewField.java    From kfs with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Renders a dynamic field label
 *
 * @param pageContext the page context to render to
 * @param parentTag the parent tag requesting this rendering
 * @param accountingLine the line which owns the field being rendered
 * @param accountingLinePropertyPath the path from the form to the accounting line
 */
protected void renderDynamicNameLabel(PageContext pageContext, Tag parentTag, AccountingLineRenderingContext renderingContext) throws JspException {
    AccountingLine accountingLine = renderingContext.getAccountingLine();
    String accountingLinePropertyPath = renderingContext.getAccountingLinePropertyPath();

    DynamicNameLabelRenderer renderer = new DynamicNameLabelRenderer();
    if (definition.getDynamicNameLabelGenerator() != null) {
        renderer.setFieldName(definition.getDynamicNameLabelGenerator().getDynamicNameLabelFieldName(accountingLine, accountingLinePropertyPath));
        renderer.setFieldValue(definition.getDynamicNameLabelGenerator().getDynamicNameLabelValue(accountingLine, accountingLinePropertyPath));
    }
    else {
        if (!StringUtils.isBlank(getField().getPropertyValue())) {
            if (getField().isSecure()) {
                renderer.setFieldValue(getField().getDisplayMask().maskValue(getField().getPropertyValue()));
            }
            else {
                renderer.setFieldValue(getDynamicNameLabelDisplayedValue(accountingLine));
            }
        }
        renderer.setFieldName(accountingLinePropertyPath + "." + definition.getDynamicLabelProperty());
    }
    renderer.render(pageContext, parentTag);
    renderer.clear();
}
 
Example #12
Source File: SetLoggerTagTest.java    From logging-log4j2 with Apache License 2.0 6 votes vote down vote up
@Test
public void testDoEndTagLoggerVarSessionScope() throws Exception {
    this.tag.setLogger(LogManager.getLogger("testDoEndTagLoggerVarSessionScope"));

    this.tag.setVar("helloWorld");
    this.tag.setScope("session");

    assertNull("The default logger should be null.", TagUtils.getDefaultLogger(this.context));
    assertEquals("The return value is not correct.", Tag.EVAL_PAGE, this.tag.doEndTag());
    assertNull("The default logger should still be null.", TagUtils.getDefaultLogger(this.context));

    final Object attribute = this.context.getAttribute("helloWorld", PageContext.SESSION_SCOPE);
    assertNotNull("The attribute should not be null.", attribute);
    assertTrue("The attribute should be a Log4jTaglibLogger.", attribute instanceof Log4jTaglibLogger);

    final Log4jTaglibLogger logger = (Log4jTaglibLogger)attribute;
    assertEquals("The logger name is not correct.", "testDoEndTagLoggerVarSessionScope", logger.getName());
}
 
Example #13
Source File: DumpTagTest.java    From logging-log4j2 with Apache License 2.0 6 votes vote down vote up
@Test
public void testDoEndTagDefaultPageScope() throws Exception {
    this.context.setAttribute("testAttribute01", "testValue01", PageContext.PAGE_SCOPE);
    this.context.setAttribute("anotherAttribute02", "finalValue02", PageContext.PAGE_SCOPE);
    this.context.setAttribute("badAttribute03", "skippedValue03", PageContext.SESSION_SCOPE);

    final int returnValue = this.tag.doEndTag();
    assertEquals("The return value is not correct.", Tag.EVAL_PAGE, returnValue);

    this.writer.flush();
    final String output = new String(this.output.toByteArray(), UTF8);
    assertEquals("The output is not correct.",
            "<dl>" +
                    "<dt><code>testAttribute01</code></dt><dd><code>testValue01</code></dd>" +
                    "<dt><code>anotherAttribute02</code></dt><dd><code>finalValue02</code></dd>" +
                    "</dl>", output);
}
 
Example #14
Source File: HtmlEscapeTagTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void escapeBodyWithHtmlEscape() throws JspException {
	PageContext pc = createPageContext();
	final StringBuffer result = new StringBuffer();
	EscapeBodyTag tag = new EscapeBodyTag() {
		@Override
		protected String readBodyContent() {
			return "test & text";
		}
		@Override
		protected void writeBodyContent(String content) {
			result.append(content);
		}
	};
	tag.setPageContext(pc);
	tag.setHtmlEscape(true);
	assertEquals(BodyTag.EVAL_BODY_BUFFERED, tag.doStartTag());
	assertEquals(Tag.SKIP_BODY, tag.doAfterBody());
	assertEquals("test &amp; text", result.toString());
}
 
Example #15
Source File: JspContextWrapper.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
public JspContextWrapper(JspContext jspContext,
        ArrayList<String> nestedVars, ArrayList<String> atBeginVars,
        ArrayList<String> atEndVars, Map<String,String> aliases) {
    this.invokingJspCtxt = (PageContext) jspContext;
    if (jspContext instanceof JspContextWrapper) {
        rootJspCtxt = ((JspContextWrapper)jspContext).rootJspCtxt;
    }
    else {
        rootJspCtxt = invokingJspCtxt;
    }
    this.nestedVars = nestedVars;
    this.atBeginVars = atBeginVars;
    this.atEndVars = atEndVars;
    this.pageAttributes = new HashMap<String, Object>(16);
    this.aliases = aliases;

    if (nestedVars != null) {
        this.originalNestedVars = new HashMap<String, Object>(nestedVars.size());
    }
    syncBeginTagFile();
}
 
Example #16
Source File: UrlTag.java    From subsonic with GNU General Public License v3.0 6 votes vote down vote up
public int doEndTag() throws JspException {

        // Rewrite and encode the url.
        String result = formatUrl();

        // Store or print the output
        if (var != null)
            pageContext.setAttribute(var, result, PageContext.PAGE_SCOPE);
        else {
            try {
                pageContext.getOut().print(result);
            } catch (IOException x) {
                throw new JspTagException(x);
            }
        }
        return EVAL_PAGE;
    }
 
Example #17
Source File: AccountingLineTableHeaderRenderer.java    From kfs with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Renders the show/hide button  
 * @param pageContext the page context to render to
 * @param parentTag the tag requesting all this rendering
 * @throws JspException thrown under terrible circumstances when the rendering failed and had to be left behind like so much refuse
 */
protected void renderHideDetails(PageContext pageContext, Tag parentTag) throws JspException {
    hideStateTag.setPageContext(pageContext);
    hideStateTag.setParent(parentTag);

    hideStateTag.doStartTag();
    hideStateTag.doEndTag();
    
    String toggle = hideDetails ? "show" : "hide";
    
    showHideTag.setPageContext(pageContext);
    showHideTag.setParent(parentTag);
    showHideTag.setProperty("methodToCall."+toggle+"Details");
    showHideTag.setSrc(SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString("kr.externalizable.images.url")+"det-"+toggle+".gif");
    showHideTag.setAlt(toggle+" transaction details");
    showHideTag.setTitle(toggle+" transaction details");
    
    showHideTag.doStartTag();
    showHideTag.doEndTag();
}
 
Example #18
Source File: UnpagedListDisplayTagTest.java    From uyuni with GNU General Public License v2.0 6 votes vote down vote up
public void setUp() throws Exception {
    super.setUp();
    setImposteriser(ClassImposteriser.INSTANCE);
    RhnBaseTestCase.disableLocalizationServiceLogging();

    request = mock(HttpServletRequest.class);
    response = mock(HttpServletResponse.class);
    context = mock(PageContext.class);
    writer = new RhnMockJspWriter();

    ldt = new UnpagedListDisplayTag();
    lt = new ListTag();
    ldt.setPageContext(context);
    ldt.setParent(lt);

    lt.setPageList(new DataResult(CSVWriterTest.getTestListOfMaps()));

    context().checking(new Expectations() { {
        atLeast(1).of(context).getOut();
        will(returnValue(writer));
        atLeast(1).of(context).getRequest();
        will(returnValue(request));
        atLeast(1).of(context).setAttribute("current", null);
    } });
}
 
Example #19
Source File: MessageOpenTag.java    From JspMyAdmin2 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void doTag() throws JspException {
	PageContext pageContext = (PageContext) super.getJspContext();
	HttpSession httpSession = pageContext.getSession();
	MessageReader messageReader = null;
	if (httpSession != null) {
		Object temp = httpSession
				.getAttribute(Constants.SESSION_LOCALE);
		if (temp != null) {
			messageReader = new MessageReader(temp.toString());
		} else {
			messageReader = new MessageReader(null);
		}
	} else {
		messageReader = new MessageReader(null);
	}
	pageContext.setAttribute(Constants.PAGE_CONTEXT_MESSAGES,
			messageReader, PageContext.PAGE_SCOPE);
}
 
Example #20
Source File: MessageTagTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void messageTagWithCodeAndArguments() throws JspException {
	PageContext pc = createPageContext();
	final StringBuffer message = new StringBuffer();
	MessageTag tag = new MessageTag() {
		@Override
		protected void writeMessage(String msg) {
			message.append(msg);
		}
	};
	tag.setPageContext(pc);
	tag.setCode("testArgs");
	tag.setArguments("arg1,arg2");
	assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
	assertEquals("Correct doEndTag return value", Tag.EVAL_PAGE, tag.doEndTag());
	assertEquals("Correct message", "test arg1 message arg2", message.toString());
}
 
Example #21
Source File: RenderTimeTableTag.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Method generateTimeTable.
 *
 * @param startTimeTableHour
 *
 * @param listaAulas
 * @return TimeTable
 */
private TimeTable generateTimeTable(List lessonList, Locale locale, PageContext pageContext, Integer startTimeTableHour) {

    Calendar calendar = Calendar.getInstance();

    calendar.set(Calendar.HOUR_OF_DAY, startTimeTableHour.intValue());
    calendar.set(Calendar.MINUTE, 0);

    Integer numberOfDays = new Integer(6);
    Integer numberOfHours =
            new Integer((endTimeTableHour.intValue() - startTimeTableHour.intValue()) * (60 / slotSizeMinutes.intValue()));

    TimeTable timeTable = new TimeTable(numberOfHours, numberOfDays, calendar, slotSizeMinutes, locale, pageContext);
    Iterator lessonIterator = lessonList.iterator();

    while (lessonIterator.hasNext()) {
        InfoShowOccupation infoShowOccupation = (InfoShowOccupation) lessonIterator.next();
        timeTable.addLesson(infoShowOccupation);
    }
    return timeTable;
}
 
Example #22
Source File: Functions.java    From packagedrone with Eclipse Public License 1.0 6 votes vote down vote up
public static List<String> errors ( final PageContext pageContext, final String command, final String path, final boolean local )
{
    final BindingResult br = (BindingResult)pageContext.getRequest ().getAttribute ( BindingResult.ATTRIBUTE_NAME );
    if ( br == null )
    {
        return Collections.emptyList ();
    }

    BindingResult result = br.getChild ( command );
    if ( result == null )
    {
        return Collections.emptyList ();
    }

    if ( path != null && !path.isEmpty () )
    {
        result = result.getChild ( path );
        if ( result == null )
        {
            return Collections.emptyList ();
        }
    }

    return ( local ? result.getLocalErrors () : result.getErrors () ).stream ().map ( err -> err.getMessage () ).collect ( Collectors.toList () );
}
 
Example #23
Source File: BindTagTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void bindTagWithToStringAndHtmlEscaping() throws JspException {
	PageContext pc = createPageContext();
	BindTag tag = new BindTag();
	tag.setPageContext(pc);
	tag.setPath("tb.doctor");
	tag.setHtmlEscape(true);
	TestBean tb = new TestBean("somebody", 99);
	NestedTestBean ntb = new NestedTestBean("juergen&eva");
	tb.setDoctor(ntb);
	pc.getRequest().setAttribute("tb", tb);
	tag.doStartTag();
	BindStatus status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
	assertEquals("doctor", status.getExpression());
	assertTrue(status.getValue() instanceof NestedTestBean);
	assertTrue(status.getDisplayValue().contains("juergen&amp;eva"));
}
 
Example #24
Source File: MessageTagTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void messageTagWithText() throws JspException {
	PageContext pc = createPageContext();
	final StringBuffer message = new StringBuffer();
	MessageTag tag = new MessageTag() {
		@Override
		protected void writeMessage(String msg) {
			message.append(msg);
		}
	};
	tag.setPageContext(pc);
	tag.setText("test & text é");
	tag.setHtmlEscape(true);
	assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
	assertEquals("Correct doEndTag return value", Tag.EVAL_PAGE, tag.doEndTag());
	assertTrue("Correct message", message.toString().startsWith("test &amp; text &"));
}
 
Example #25
Source File: MessageTagTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void messageWithVar() throws JspException {
	PageContext pc = createPageContext();
	MessageTag tag = new MessageTag();
	tag.setPageContext(pc);
	tag.setText("text & text");
	tag.setVar("testvar");
	tag.doStartTag();
	assertEquals("Correct doEndTag return value", Tag.EVAL_PAGE, tag.doEndTag());
	assertEquals("text & text", pc.getAttribute("testvar"));
	tag.release();

	// try to reuse
	tag.setPageContext(pc);
	tag.setCode("test");
	tag.setVar("testvar");

	tag.doStartTag();
	assertEquals("Correct doEndTag return value", Tag.EVAL_PAGE, tag.doEndTag());
	assertEquals("Correct message", "test message", pc.getAttribute("testvar"));
}
 
Example #26
Source File: Util.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Utility methods
 * taken from org.apache.taglibs.standard.tag.common.core.UrlSupport
 * @param url The URL
 * @param context The context
 * @param pageContext The page context
 * @return the absolute URL
 * @throws JspException If the URL doesn't start with '/'
 */
public static String resolveUrl(
        String url, String context, PageContext pageContext)
throws JspException {
    // don't touch absolute URLs
    if (isAbsoluteUrl(url))
        return url;

    // normalize relative URLs against a context root
    HttpServletRequest request =
        (HttpServletRequest) pageContext.getRequest();
    if (context == null) {
        if (url.startsWith("/"))
            return (request.getContextPath() + url);
        else
            return url;
    } else {
        if (!context.startsWith("/") || !url.startsWith("/")) {
            throw new JspTagException(
            "In URL tags, when the \"context\" attribute is specified, values of both \"context\" and \"url\" must start with \"/\".");
        }
        if (context.equals("/")) {
            // Don't produce string starting with '//', many
            // browsers interpret this as host name, not as
            // path on same host.
            return url;
        } else {
            return (context + url);
        }
    }
}
 
Example #27
Source File: PageContextImpl.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
public static void setMethodVariable(PageContext pageContext,
                                     String variable,
                                     MethodExpression expression) {
    ExpressionFactory expFactory = getExpressionFactory(pageContext);
    ValueExpression exp =
        expFactory.createValueExpression(expression, Object.class);
    setValueVariable(pageContext, variable, exp);
}
 
Example #28
Source File: JspFragmentHelper.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
public JspFragmentHelper( int discriminator, JspContext jspContext,
    JspTag parentTag )
{
    this.discriminator = discriminator;
    this.jspContext = jspContext;
    if(jspContext instanceof PageContext) {
        _jspx_page_context = (PageContext)jspContext;
    } else {
        _jspx_page_context = null;
    }
    this.parentTag = parentTag;
}
 
Example #29
Source File: ColumnTag.java    From uyuni with GNU General Public License v2.0 5 votes vote down vote up
protected void renderUnbound() throws JspException {
    ListTag parent = (ListTag)
        BodyTagSupport.findAncestorWithClass(this, ListTag.class);
    if (attributeName != null) {
        Object bean = parent.getCurrentObject();
        String value = ListTagUtil.getBeanValue(bean, attributeName);
        pageContext.setAttribute("beanValue", value, PageContext.PAGE_SCOPE);
    }
    writeStartingTd();
}
 
Example #30
Source File: AbstractFunction.java    From ontopia with Apache License 2.0 5 votes vote down vote up
@Override
public Collection execute(PageContext pageContext, TagSupport callingTag)
  throws IOException, JspException {
  // Delegate to deprecated call method.
  call(pageContext, callingTag);
  // Return value
  String retvar = getReturnVariableName();
  if (retvar != null) {
    // Note: may throw VariableNotSetException if variable not set.
    return ContextUtils.getValue(retvar, pageContext);
  }
  return null;
}