Overview of themes
You can apply Spring Web MVC frame work themes to set the overall look-and-feel of your application, thereby enhancing user experience.A theme is a collection of static resources, typically style sheets and images, that affect the visual style of the application.
To use themes in your web application, you must set up an implementation of the org. spring frame work. ui. context.Theme Source interface.The Web Application Context interface extends Theme Source but delegates its responsibilities to a dedicated implementation.By default the delegate will be an org .spring frame work. ui. context.support.ResourceBundleThemeSource implementation that loads properties files from the root of the classpath.To use a custom Theme Source implementation or to configure the base name prefix of the Resource Bundle Theme Source, you can register a bean in the application context with the reserved name theme Source. The web application context automatically detects a bean with that name and uses it.
When using the Resource Bundle Theme Source, a theme is defined in a simple properties file.The properties file lists the resources that make up the theme. Here is an example:
The keys of the properties are the names that refer to the themed elements from view code. For a JSP, you typically do this using the spring:theme custom tag, which is very similar to the spring:message tag.The following JSP fragment uses the theme defined in the previous example to customize the look and feel:<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
By default, the Resource Bundle Theme Source uses an empty base name prefix. As a result, the properties files are loaded from the root of the class path.Thus you would put the cool.properties theme definition in a directory at the root of the classpath, for example, in /WEB-INF/classes. The Resource Bundle Theme Source uses the standard Java resource bundle loading mechanism, allowing for full internationalization of themes. For example, we could have a /WEB-INF/classes/cool_nl.properties that references a special background image with Dutch text on it.
After you define themes you decide which theme to use. The Dispatcher Servlet will look for a bean named theme Resolver to find out which Theme Resolver implementation to use. A theme resolver works in much the same way as a Locale Resolver.It detects the theme to use for a particular request and can also alter the request's theme.The following theme resolvers are provided by Spring:
Table Theme Resolver implementations
Spring also provides a Theme Change Interceptor that allows theme changes on every request with a simple request parameter.
Java-Springs Related Interview Questions
|Adv Java Interview Questions||J2EE Interview Questions|
|Core Java Interview Questions||JSP Interview Questions|
|Java-Springs Interview Questions||Java Servlets Interview Questions|
|JMS(Java Message Service) Interview Questions||Hibernate Interview Questions|
|Java applet Interview Questions||Java Interview Questions|
|Framework7 Interview Questions||Java collections framework Interview Questions|
|Java 8 Interview Questions||Java Programmer Interview Questions|
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.