Skip to content

Struts Framework

August 6, 2009
tags:

Struts is a Java-based framework used to build web applications.

Design Features and goals:
Open source

Based on the Model-View-Controller (MVC) design paradigm, distinctly separating all three
levels:
Model: application state
View: presentation of data (JSP, HTML)
Controller: routing of the application flow

Implements the JSP Model 2 Architecture

Stores application routing information and request mapping in a single core file, struts-config.xml

Main goal is to separate the Model from the view and the controller.

MVC:

The Model-View-Controller pattern is one of the earliest and one of the most successful design patterns.

It was developed by Trygve Reenskaug in 1979
It is a architectural pattern.

It is a Multitier Architecture.

In Complex computer applications that present large amount of data to the user, a developer often wishes to separate data and user interface concerns, so changes to the user interface will not affect data handling and the data can be reorganized without changing the user interface.

In this scenario, MVC solve this problem easily

For Example:

In a Web application

View- is the HTML page

Controller-Code that gathers dynamic data generates the content with in the

HTML.

Model-Content stored in the database or XML file
VIEW:

View is the graphical data presentation (outputting) irrespective of the real data processing.

View is the responsible for look and feel, some custom formatting, sorting etc.

View is completely isolated from actual complex data operations.

The beauty of MVC approach is that it supports any kind of view, which is challenging in todays distributed and multi-platform environment.

A MVC model can have multiple views, which are controlled by controller. View interface can be of WEB-FORMS, HTML, XML/XSLT, XTML, and WML or can be Windows forms etc.

MODEL:

Model is responsible for actual data processing, like database connection, querying database, implementing business rules etc.

It feeds data to the view without worrying about the actual formatting and look and feel.

Data provided by Model is display-neutral so it can be interfaced with as many views without code redundancy; this eases your code maintenance and reduces bugs and allows code -reuse at good extent.

Model responds to the request made by controllers and notifies the registered views to update their display with new data.

CONTROLLER:

Controller is responsible for Notice of action.

Controller responds to the mouse or keyboard input to command model and view to change.

Controllers are associated with views.

User interaction triggers the events to change the model, which in turn calls some methods of model to update its state to notify other registered views to refresh their display.

There are two kinds of controllers:
Scheduled controllers .

Unscheduled controllers.

Benefits:

Easier to Maintain,test and upgrade

Easier to add new clients just by adding their view and controller.

Extensible and scalable

Reusability and Modularity

Drawbacks:

For designing requires high-skilled experienced professionals.

Requires more amount of time to analyze and design.

While this approach is not suitable for smaller Applications

Advertisements
No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: