org.springframework.web.servlet.view.script.ScriptTemplateConfigurer Java Examples

The following examples show how to use org.springframework.web.servlet.view.script.ScriptTemplateConfigurer. 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: IsomorphicApplication.java    From spring-react-isomorphic with Apache License 2.0 6 votes vote down vote up
@Bean
    public ScriptTemplateConfigurer reactConfigurer() {
        ScriptTemplateConfigurer configurer = new ScriptTemplateConfigurer();
        configurer.setEngineName("nashorn");
        configurer.setScripts("static/polyfill.js",
                "static/lib/js/ejs.min.js",
                "/META-INF/resources/webjars/react/0.13.1/react.js",
//                "/META-INF/resources/webjars/react/0.13.1/JSXTransformer.js",
                "static/render.js",
                "static/output/comment.js",
                "static/output/comment-form.js",
                "static/output/comment-list.js");
        configurer.setRenderFunction("render");
        configurer.setSharedEngine(false);
        return configurer;
    }
 
Example #2
Source File: ViewResolverRegistry.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Register a script template view resolver with an empty default view name prefix and suffix.
 * @since 4.2
 */
public UrlBasedViewResolverRegistration scriptTemplate() {
	if (!checkBeanOfType(ScriptTemplateConfigurer.class)) {
		throw new BeanInitializationException("In addition to a script template view resolver " +
				"there must also be a single ScriptTemplateConfig bean in this web application context " +
				"(or its parent): ScriptTemplateConfigurer is the usual implementation. " +
				"This bean may be given any name.");
	}
	ScriptRegistration registration = new ScriptRegistration();
	this.viewResolvers.add(registration.getViewResolver());
	return registration;
}
 
Example #3
Source File: ViewResolverRegistryTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Before
public void setup() {
	StaticWebApplicationContext context = new StaticWebApplicationContext();
	context.registerSingleton("freeMarkerConfigurer", FreeMarkerConfigurer.class);
	context.registerSingleton("tilesConfigurer", TilesConfigurer.class);
	context.registerSingleton("groovyMarkupConfigurer", GroovyMarkupConfigurer.class);
	context.registerSingleton("scriptTemplateConfigurer", ScriptTemplateConfigurer.class);

	this.registry = new ViewResolverRegistry(new ContentNegotiationManager(), context);
}
 
Example #4
Source File: ViewResolverRegistry.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Register a script template view resolver with an empty default view name prefix and suffix.
 * @since 4.2
 */
public UrlBasedViewResolverRegistration scriptTemplate() {
	if (!checkBeanOfType(ScriptTemplateConfigurer.class)) {
		throw new BeanInitializationException("In addition to a script template view resolver " +
				"there must also be a single ScriptTemplateConfig bean in this web application context " +
				"(or its parent): ScriptTemplateConfigurer is the usual implementation. " +
				"This bean may be given any name.");
	}
	ScriptRegistration registration = new ScriptRegistration();
	this.viewResolvers.add(registration.getViewResolver());
	return registration;
}
 
Example #5
Source File: ViewResolverRegistryTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Before
public void setup() {
	StaticWebApplicationContext context = new StaticWebApplicationContext();
	context.registerSingleton("freeMarkerConfigurer", FreeMarkerConfigurer.class);
	context.registerSingleton("tilesConfigurer", TilesConfigurer.class);
	context.registerSingleton("groovyMarkupConfigurer", GroovyMarkupConfigurer.class);
	context.registerSingleton("scriptTemplateConfigurer", ScriptTemplateConfigurer.class);

	this.registry = new ViewResolverRegistry(new ContentNegotiationManager(), context);
}
 
Example #6
Source File: ViewResolverRegistry.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Register a script template view resolver with an empty default view name prefix and suffix.
 * @since 4.2
 */
public UrlBasedViewResolverRegistration scriptTemplate() {
	if (!checkBeanOfType(ScriptTemplateConfigurer.class)) {
		throw new BeanInitializationException("In addition to a script template view resolver " +
				"there must also be a single ScriptTemplateConfig bean in this web application context " +
				"(or its parent): ScriptTemplateConfigurer is the usual implementation. " +
				"This bean may be given any name.");
	}
	ScriptRegistration registration = new ScriptRegistration();
	this.viewResolvers.add(registration.getViewResolver());
	return registration;
}
 
Example #7
Source File: ViewResolverRegistry.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Register a script template view resolver with an empty default view name prefix and suffix.
 * @since 4.2
 */
public UrlBasedViewResolverRegistration scriptTemplate() {
	if (this.applicationContext != null && !hasBeanOfType(ScriptTemplateConfigurer.class)) {
		throw new BeanInitializationException("In addition to a script template view resolver " +
				"there must also be a single ScriptTemplateConfig bean in this web application context " +
				"(or its parent): ScriptTemplateConfigurer is the usual implementation. " +
				"This bean may be given any name.");
	}
	ScriptRegistration registration = new ScriptRegistration();
	this.viewResolvers.add(registration.getViewResolver());
	return registration;
}
 
Example #8
Source File: ViewResolverRegistryTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
	StaticWebApplicationContext context = new StaticWebApplicationContext();
	context.registerSingleton("freeMarkerConfigurer", FreeMarkerConfigurer.class);
	context.registerSingleton("velocityConfigurer", VelocityConfigurer.class);
	context.registerSingleton("tilesConfigurer", TilesConfigurer.class);
	context.registerSingleton("groovyMarkupConfigurer", GroovyMarkupConfigurer.class);
	context.registerSingleton("scriptTemplateConfigurer", ScriptTemplateConfigurer.class);
	this.registry = new ViewResolverRegistry();
	this.registry.setApplicationContext(context);
	this.registry.setContentNegotiationManager(new ContentNegotiationManager());
}
 
Example #9
Source File: ScriptTemplateApplication.java    From spring-boot-sample-web-handlebars with Apache License 2.0 5 votes vote down vote up
@Bean
public ScriptTemplateConfigurer handlebarsConfigurer() {
ScriptTemplateConfigurer configurer = new ScriptTemplateConfigurer();
	configurer.setEngineName("nashorn");
		configurer.setScripts("/static/polyfill.js",
			"/META-INF/resources/webjars/handlebars/3.0.0-1/handlebars.js",
			"/static/render.js");
	configurer.setRenderFunction("render");
	configurer.setSharedEngine(false);
	return configurer;
}