Package org.springframework.web.servlet.support

Examples of org.springframework.web.servlet.support.RequestContext


   * @see net.sf.jasperreports.engine.JRParameter#REPORT_LOCALE
   * @see net.sf.jasperreports.engine.JRParameter#REPORT_RESOURCE_BUNDLE
   * @see org.springframework.web.servlet.support.JstlUtils#exposeLocalizationContext
   */
  protected void exposeLocalizationContext(Map<String, Object> model, HttpServletRequest request) {
    RequestContext rc = new RequestContext(request, getServletContext());
    if (!model.containsKey(JRParameter.REPORT_LOCALE)) {
      model.put(JRParameter.REPORT_LOCALE, rc.getLocale());
    }
    JasperReport report = getReport();
    if ((report == null || report.getResourceBundle() == null) &&
        !model.containsKey(JRParameter.REPORT_RESOURCE_BUNDLE)) {
      model.put(JRParameter.REPORT_RESOURCE_BUNDLE,
          new MessageSourceResourceBundle(rc.getMessageSource(), rc.getLocale()));
    }
  }
View Full Code Here


   * @see org.springframework.web.servlet.support.RequestContext
   */
  protected RequestContext createRequestContext(
      HttpServletRequest request, HttpServletResponse response, Map<String, Object> model) {

    return new RequestContext(request, response, getServletContext(), model);
  }
View Full Code Here

@Deprecated
public class TilesJstlView extends TilesView {

  @Override
  protected void exposeHelpers(HttpServletRequest request) throws Exception {
    JstlUtils.exposeLocalizationContext(new RequestContext(request, getServletContext()));
  }
View Full Code Here

            "Cannot expose bind macro helper '" + SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE +
            "' because of an existing model object of the same name");
      }
      // Expose RequestContext instance for Spring macros.
      model.put(SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE,
          new RequestContext(request, getServletContext(), model));
    }

    applyContentType(response);

    renderMergedTemplateModel(model, request, response);
View Full Code Here

            "Cannot expose bind macro helper '" + SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE +
            "' because of an existing model object of the same name");
      }
      // Expose RequestContext instance for Spring macros.
      model.put(SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE,
          new RequestContext(request, getServletContext(), model));
    }

    applyContentType(response);

    renderMergedTemplateModel(model, request, response);
View Full Code Here

   * @return the RequestContext instance
   * @see #setRequestContextAttribute
   * @see org.springframework.web.servlet.support.RequestContext
   */
  protected RequestContext createRequestContext(HttpServletRequest request, Map model) {
    return new RequestContext(request, getServletContext(), model);
  }
View Full Code Here

  /**
   * @see org.springframework.web.servlet.support.RequestContext#getBindStatus(String)
   */
  public BindStatus getBindStatus(String path) throws IllegalStateException {
    return new BindStatus(new RequestContext(this.request), path, false);
  }
View Full Code Here

  /**
   * @see org.springframework.web.servlet.support.RequestContext#getBindStatus(String, boolean)
   */
  public BindStatus getBindStatus(String path, boolean htmlEscape) throws IllegalStateException {
    return new BindStatus(new RequestContext(this.request), path, true);
  }
View Full Code Here

    tag.doStartTag();
  }

  public void testRequestContext() throws ServletException {
    PageContext pc = createPageContext();
    RequestContext rc = new RequestContext((HttpServletRequest) pc.getRequest(), pc.getServletContext());
    assertEquals("test message", rc.getMessage("test"));
    assertEquals("test message", rc.getMessage("test", (Object[]) null));
    assertEquals("test message", rc.getMessage("test", "default"));
    assertEquals("test message", rc.getMessage("test", (Object[]) null, "default"));
    assertEquals("test arg1 message arg2",
        rc.getMessage("testArgs", new String[] {"arg1", "arg2"}, "default"));
    assertEquals("test arg1 message arg2",
        rc.getMessage("testArgs", Arrays.asList(new String[] {"arg1", "arg2"}), "default"));
    assertEquals("default", rc.getMessage("testa", "default"));
    assertEquals("default", rc.getMessage("testa", (List) null, "default"));
    MessageSourceResolvable resolvable = new DefaultMessageSourceResolvable(new String[] {"test"});
    assertEquals("test message", rc.getMessage(resolvable));
  }
View Full Code Here

    MockHttpServletResponse response = new MockHttpServletResponse();

    simpleDispatcherServlet.service(request, response);
    assertTrue("forwarded to form", "form".equals(response.getForwardedUrl()));
    DefaultMessageSourceResolvable resolvable = new DefaultMessageSourceResolvable(new String[] {"test"});
    RequestContext rc = new RequestContext(request);

    assertTrue("hasn't RequestContext attribute", request.getAttribute("rc") == null);
    assertTrue("Correct WebApplicationContext",
        RequestContextUtils.getWebApplicationContext(request) instanceof SimpleWebApplicationContext);
    assertTrue("Correct context path", rc.getContextPath().equals(request.getContextPath()));
    assertTrue("Correct locale", Locale.CANADA.equals(RequestContextUtils.getLocale(request)));
    assertTrue("Correct theme",
        AbstractThemeResolver.ORIGINAL_DEFAULT_THEME_NAME.equals(RequestContextUtils.getTheme(request).getName()));
    assertTrue("Correct message", "Canadian & test message".equals(rc.getMessage("test")));

    assertTrue("Correct WebApplicationContext", rc.getWebApplicationContext() == simpleDispatcherServlet.getWebApplicationContext());
    assertTrue("Correct Errors", !(rc.getErrors(BaseCommandController.DEFAULT_COMMAND_NAME) instanceof EscapedErrors));
    assertTrue("Correct Errors", !(rc.getErrors(BaseCommandController.DEFAULT_COMMAND_NAME, false) instanceof EscapedErrors));
    assertTrue("Correct Errors", rc.getErrors(BaseCommandController.DEFAULT_COMMAND_NAME, true) instanceof EscapedErrors);
    assertEquals("Correct message", "Canadian & test message", rc.getMessage("test"));
    assertEquals("Correct message", "Canadian & test message", rc.getMessage("test", null, false));
    assertEquals("Correct message", "Canadian &amp; test message", rc.getMessage("test", null, true));
    assertEquals("Correct message", "Canadian & test message", rc.getMessage(resolvable));
    assertEquals("Correct message", "Canadian & test message", rc.getMessage(resolvable, false));
    assertEquals("Correct message", "Canadian &amp; test message", rc.getMessage(resolvable, true));
    assertEquals("Correct message", "Canadian & test message", rc.getMessage("test", "default"));
    assertEquals("Correct message", "default", rc.getMessage("testa", "default"));
    assertEquals("Correct message", "default &amp;", rc.getMessage("testa", null, "default &", true));
  }
View Full Code Here

TOP

Related Classes of org.springframework.web.servlet.support.RequestContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.