View RSS Feed

Spring Framework

Using View Helper in Spring MVC

Rate this Entry
by , 11-16-2011 at 04:08 PM (2798 Views)
When you are looking to create the web front-end to your application, anyone with exposure to design patterns would apply the MVC pattern for this aspect of the application. There are a number of ways to do this, in Spring Framework, the means of accomplishing this is via an application controller and page controllers combined with a gateway servlet. This design resolves three important concerns of request processing:
  1. Request interception
  2. Invoking business components from page controllers
  3. Resolving the next view to be displayed with the data returned from business layer


The page controllers return data as a result of invoking the business logic. The data is consumed by the view components to provide a dynamic response. JSP as the view technology. The data returned by the business components was set as request attributes. It was later retrieved, processed, and used in the JSPs using scriptlets. The benefits of this approach are the following:
Achieve a division of labor between Java developers and web page authors.
Remove the programming logic from the template-based views like JSPs.
Create reusable components that can be used to combine model data across views.

If you use view helpers to adapt model data with the view components in the presentation layer, you can separate the logic for retrieving and processing model data from the static markup in the JSPs. It also allows for proper formatting of various data types such as currencies, date, telephone numbers, etc.

Name:  ViewHelpers.jpg
Views: 847
Size:  39.4 KB

Working of a view helper

JavaBeans View Helper
This is the simplest form of view helper strategy. JSP provides out-of-the-box tags to support POJO view helpers. The page controller is responsible for invoking the business object, which returns POJOs to be populated in views. The controller that binds the transfer object in the request scope.

Submit "Using View Helper in Spring MVC" to Facebook Submit "Using View Helper in Spring MVC" to Digg Submit "Using View Helper in Spring MVC" to del.icio.us Submit "Using View Helper in Spring MVC" to StumbleUpon Submit "Using View Helper in Spring MVC" to Google

Categories
View Helper , MVC

Comments