Search in sources :

Example 6 with RequestDataValueProcessor

use of org.springframework.web.servlet.support.RequestDataValueProcessor in project spring-framework by spring-projects.

the class UrlTag method doEndTag.

@Override
public int doEndTag() throws JspException {
    String url = createUrl();
    RequestDataValueProcessor processor = getRequestContext().getRequestDataValueProcessor();
    ServletRequest request = this.pageContext.getRequest();
    if ((processor != null) && (request instanceof HttpServletRequest)) {
        url = processor.processUrl((HttpServletRequest) request, url);
    }
    if (this.var == null) {
        // print the url to the writer
        try {
            pageContext.getOut().print(url);
        } catch (IOException ex) {
            throw new JspException(ex);
        }
    } else {
        // store the url as a variable
        pageContext.setAttribute(var, url, scope);
    }
    return EVAL_PAGE;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletRequest(javax.servlet.ServletRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) JspException(javax.servlet.jsp.JspException) RequestDataValueProcessor(org.springframework.web.servlet.support.RequestDataValueProcessor) IOException(java.io.IOException)

Example 7 with RequestDataValueProcessor

use of org.springframework.web.servlet.support.RequestDataValueProcessor in project spring-framework by spring-projects.

the class AbstractDataBoundFormElementTag method processFieldValue.

/**
	 * Process the given form field through a {@link RequestDataValueProcessor}
	 * instance if one is configured or otherwise returns the same value.
	 */
protected final String processFieldValue(String name, String value, String type) {
    RequestDataValueProcessor processor = getRequestContext().getRequestDataValueProcessor();
    ServletRequest request = this.pageContext.getRequest();
    if (processor != null && (request instanceof HttpServletRequest)) {
        value = processor.processFormFieldValue((HttpServletRequest) request, name, value, type);
    }
    return value;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletRequest(javax.servlet.ServletRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) RequestDataValueProcessor(org.springframework.web.servlet.support.RequestDataValueProcessor)

Example 8 with RequestDataValueProcessor

use of org.springframework.web.servlet.support.RequestDataValueProcessor in project spring-framework by spring-projects.

the class FormTag method doEndTag.

/**
	 * Closes the '{@code form}' block tag and removes the form object name
	 * from the {@link javax.servlet.jsp.PageContext}.
	 */
@Override
public int doEndTag() throws JspException {
    RequestDataValueProcessor processor = getRequestContext().getRequestDataValueProcessor();
    ServletRequest request = this.pageContext.getRequest();
    if ((processor != null) && (request instanceof HttpServletRequest)) {
        writeHiddenFields(processor.getExtraHiddenFields((HttpServletRequest) request));
    }
    this.tagWriter.endTag();
    return EVAL_PAGE;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletRequest(javax.servlet.ServletRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) RequestDataValueProcessor(org.springframework.web.servlet.support.RequestDataValueProcessor)

Example 9 with RequestDataValueProcessor

use of org.springframework.web.servlet.support.RequestDataValueProcessor in project spring-framework by spring-projects.

the class AbstractHtmlElementTagTests method getMockRequestDataValueProcessor.

@SuppressWarnings("deprecation")
protected RequestDataValueProcessor getMockRequestDataValueProcessor() {
    RequestDataValueProcessor mockProcessor = mock(RequestDataValueProcessor.class);
    HttpServletRequest request = (HttpServletRequest) getPageContext().getRequest();
    StaticWebApplicationContext wac = (StaticWebApplicationContext) RequestContextUtils.findWebApplicationContext(request);
    wac.getBean(RequestDataValueProcessorWrapper.class).setRequestDataValueProcessor(mockProcessor);
    return mockProcessor;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) MockHttpServletRequest(org.springframework.mock.web.test.MockHttpServletRequest) RequestDataValueProcessor(org.springframework.web.servlet.support.RequestDataValueProcessor) RequestDataValueProcessorWrapper(org.springframework.web.servlet.support.RequestDataValueProcessorWrapper) StaticWebApplicationContext(org.springframework.web.context.support.StaticWebApplicationContext)

Aggregations

RequestDataValueProcessor (org.springframework.web.servlet.support.RequestDataValueProcessor)9 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 ServletRequest (javax.servlet.ServletRequest)4 Test (org.junit.Test)4 StaticWebApplicationContext (org.springframework.web.context.support.StaticWebApplicationContext)3 RequestDataValueProcessorWrapper (org.springframework.web.servlet.support.RequestDataValueProcessorWrapper)3 MockServletContext (org.springframework.mock.web.test.MockServletContext)2 ModelMap (org.springframework.ui.ModelMap)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 JspException (javax.servlet.jsp.JspException)1 MockHttpServletRequest (org.springframework.mock.web.test.MockHttpServletRequest)1 CsrfToken (org.springframework.security.web.csrf.CsrfToken)1 DefaultCsrfToken (org.springframework.security.web.csrf.DefaultCsrfToken)1 ContextLoader (org.springframework.web.context.ContextLoader)1