MVC

An often posed question is which parts represents model, view and controller in JSF. After reading some different opinions to this topic, i show here the division and naming convention used on this site:

Model

The model contains POJO classes, which only store the data used in the view. I do not use any suffix for the model classes, so its better readable in the pages.

Package:
de.icoding.model.forum
Classes:
Forum, ForumEntry

For management of master data i use normally two classes:

Forum
contains all data of an entity, used for creating/editing
ForumEntry
represents a single list entity with only the essential data

View

The view includes the JSF pages and the backing beans, which contain view depending code to control the components. I choose suffix View for this classes because its more readable than Backing inside the pages.

Package:
de.icoding.view.forum
Classes:
ForumView, ForumListView

For management of master data i use normally two classes:

ForumView
detail view to create or edit of a single entity
ForumListView
listing the entities

Controller

The controller part is done by several classes like Filter, JSF Servlet, ViewHandler and also the Business Logic.

Package:
de.icoding.controller
Classes:
ServiceFilter, ViewHandler

The business logic is separated but belong also to the controller, because the logic methods control the navigation with special IDs. For this classes i use the suffix Action.

Package:
de.icoding.action.forum
Classes:
ForumAction

Author: Johannes HammoudComments Date: 08.11.2008

Language German

Java JSF XHTML WML JavaScript GlassFish MySQL NetBeans

Imprint

Visits
582379
Today
35