Package org.springframework.web.servlet.view.velocity

Examples of org.springframework.web.servlet.view.velocity.VelocityViewResolver


  }

  private static class VelocityRegistration extends UrlBasedViewResolverRegistration {

    private VelocityRegistration() {
      super(new VelocityViewResolver());
      getViewResolver().setSuffix(".vm");
    }
View Full Code Here


    assertEquals(".freemarker", accessor.getPropertyValue("suffix"));
    assertArrayEquals(new String[] {"my*", "*Report"}, (String[]) accessor.getPropertyValue("viewNames"));
    assertEquals(1024, accessor.getPropertyValue("cacheLimit"));

    resolver = resolvers.get(4);
    VelocityViewResolver velocityViewResolver = (VelocityViewResolver) resolver;
    accessor = new DirectFieldAccessor(resolver);
    assertEquals("", accessor.getPropertyValue("prefix"));
    assertEquals(".vm", accessor.getPropertyValue("suffix"));
    assertEquals(0, accessor.getPropertyValue("cacheLimit"));

View Full Code Here

  }

  @Test
  public void velocity() {
    this.registry.velocity().prefix("/").suffix(".vm").cache(true);
    VelocityViewResolver resolver = checkAndGetResolver(VelocityViewResolver.class);
    checkPropertyValues(resolver, "prefix", "/", "suffix", ".vm", "cacheLimit", 1024);
  }
View Full Code Here

  }

  @Test
  public void velocityDefaultValues() {
    this.registry.velocity();
    VelocityViewResolver resolver = checkAndGetResolver(VelocityViewResolver.class);
    checkPropertyValues(resolver, "prefix", "", "suffix", ".vm");
  }
View Full Code Here

        return velocityConfigurer;
    }

    @Bean
    public ViewResolver getViewResolver() {
        VelocityViewResolver velocityViewResolver = new VelocityViewResolver();
        velocityViewResolver.setSuffix(".vm");
        velocityViewResolver.setExposeRequestAttributes(true);
        velocityViewResolver.setExposeSessionAttributes(true);
        velocityViewResolver.setExposeSpringMacroHelpers(true);
        return velocityViewResolver;
    }
View Full Code Here

        return new VelocityConfigurer();
    }

    @Bean
    VelocityViewResolver velocityViewResolver() {
        VelocityViewResolver resolver = new VelocityViewResolver();
        resolver.setSuffix(this.environment.getProperty("suffix", ".vm"));
        resolver.setPrefix(this.environment.getProperty("prefix", "/templates/"));
        // Needs to come before any fallback resolver (e.g. a
        // InternalResourceViewResolver)
        resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 20);
        return resolver;
    }
View Full Code Here

    }

    @Bean
    @ConditionalOnMissingBean(name = "velocityViewResolver")
    public VelocityViewResolver velocityViewResolver() {
      VelocityViewResolver resolver = new VelocityViewResolver();
      this.properties.applyToViewResolver(resolver);
      return resolver;
    }
View Full Code Here

  }

  @Override
  public void applyToViewResolver(Object viewResolver) {
    super.applyToViewResolver(viewResolver);
    VelocityViewResolver resolver = (VelocityViewResolver) viewResolver;
    resolver.setToolboxConfigLocation(getToolboxConfigLocation());
    resolver.setDateToolAttribute(getDateToolAttribute());
    resolver.setNumberToolAttribute(getNumberToolAttribute());
  }
View Full Code Here

  public String getGreeting() {
    return "Hello World";
  }

  private MockHttpServletResponse render(String viewName) throws Exception {
    VelocityViewResolver resolver = this.context.getBean(VelocityViewResolver.class);
    View view = resolver.resolveViewName(viewName, Locale.UK);
    assertThat(view, notNullValue());
    HttpServletRequest request = new MockHttpServletRequest();
    request.setAttribute(RequestContext.WEB_APPLICATION_CONTEXT_ATTRIBUTE,
        this.context);
    MockHttpServletResponse response = new MockHttpServletResponse();
View Full Code Here

    }

    protected ViewResolver getVelocityViewResolver(Invocation inv, String viewPath)
            throws IOException {
        //
        VelocityViewResolver viewResolver = velocityViewResolvers.get(viewPath);
        if (viewResolver != null) {
            return viewResolver;
        }
        //
        String viewDirectory = getDirectory(viewPath);
View Full Code Here

TOP

Related Classes of org.springframework.web.servlet.view.velocity.VelocityViewResolver

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.