In JCodeBox, a web style governs how your generated web application will be configured and how it will operate at runtime. It dictates what components JCodeBox will automatically generate for you (system components i.e. an application error JSP) and how
the different parts of your web application will interact (i.e. using a front controller servlet to forward requests).
Currently there are two web style settings available (in JCodeBox system options):
None
No web style will be applied to your generated web application
View helper/Service to workers (VHSTW)
The View helper/Service to workers web style will be applied to your generated web application
Web style: View helper/Service to workers (VHSTW)
VHSTW: Overview
The View helper/Service to workers web style applies the following J2EE design patterns to your generated web application:
Front controller
Provides a single, central entry point to your application.
View helper
Encapsulates business functionality and data for view components (JSP).
Service to workers
Combines the front controller and view helpers whereby the controller (with combined dispatcher) delegates processing to view helpers which then provide data for the views.
VHSTW: View paths
In JCodeBox, a view path represents a list of views (and their associated processing) required to complete an action i.e. to edit a customer record, JCodeBox creates a view path with two views; one to find the customer (i.e. findByPrimaryKey) and one to actually edit the customers details.
VHSTW: View sets
In JCodeBox, a view set represents a set of view paths for a particular entity/EJB. If you add a view set to your application in the JCodeBox GUI, at generation time JCodeBox will attempt to automatically create as many view paths for the selected entity/EJB as possible. Usually the following view paths are always created (for entities in web applications and for entity EJBs in enterprise applications):
Maintain entity
Create entity (can be affected by CMR settings)
Find entity (by primary key)
Delete entity
EJB information (for EJBs)
In addition to this, JCodeBox will attempt to create additional view paths for the following:
Additional finders
Additional creators
Business methods
BMP relationships
Data transfer patterns (i.e. Value Object)
Home methods
In general, view paths can only be created where primitive types are used i.e. a business method must only use primitive types for its parameters and for its return value.
View sets can be a massive time saver as they allow you to test many aspects of your entities/EJBs by adding a single component to your JCodeBox application.
VHSTW: System generated components
Description
Default name
Default location
Notes
System error page
SystemError.jsp
/syspages
Displays system errors
Application error page
AppError.jsp
/syspages
Displays application errors
System message page
SystemMessage.jsp
/syspages
Displays system messages
System menu page
SystemMenu.jsp
/syspages
Displays system menu. Optional - can be disabled from web tier properties
Front controller servlet
front.java
<<base package>>.servlets
Entry point to web application
View helper interface
ViewHelper.java
<<base package>>.servlets.helpers
Implemented by concrete view helpers. Contains one method definition: public void processRequest(HttpServletRequest req, HttpServletResponse resp, ServletContext sc) ;
Request helper interface
RequestHelper.java
<<base package>>.servlets.helpers
Implemented by concrete request helpers. Allows HTTP request variables to be retrieved in a protocol neutral way.
View path class
ViewPath.java
<<base package>>.servlets.helpers
Manages a view path for an action e.g. edit customer (i.e. given a view, will return the next view in the path)
View helper map class
ViewHelperMap.java
<<base package>>.servlets.helpers
Maps view helper names to their variable and class names (i.e. the CUSTOMEREJB View Set may be stored in a variable called CUSTOMEREJBViewHelperVar with a type of com.mycompany.myapp.viewhelpers.CUSTOMEREJBViewHelper)
VHSTW: request variables
Description
Variable name
Notes
The target view set for this request (if applicable)
ViewSet
If applicable, contains the target view set name. The front controller servlet uses this name to lookup the view helper that will process this request. Can contain JSPDIRECT or SRVDIRECT if front is to forward directly to a JSP or a servlet.
The target view path for this request
Path
Used by the view helper along with the source view to determine the next view to be displayed (the view helper queries the view path map object).
The source view this request originated from
SourceView
Used by the view helper along with the path to determine the next view to be displayed (the view helper queries the view path map object).
The target action for this request
Action
Used by the view helper to determine what action (processing) is being requested (e.g. maintainCUSTOMEREJB) or by the front controller to determine the name of the resource (JSP or servlet) to forward to (e.g. /somePage.jsp)
VHSTW request processing
The following diagram displays graphically how the View helper/Service to workers web style processes HTTP requests.
Steps:
A HTTP request is received
The front controller extracts the request query variables including the view set name
If the request (view set name) is for a direct resource, forward to the resource (JSP or servlet) otherwise ...
Lookup/create the view helper associated with this view set name (stored in session object)
Ask the view helper to process the request
The view helper processes the request (i.e. connects to a remote database/EJB, etc) and stores data locally
The view helper then gets the next view in the path from the view path map
The view helper then forwards the request to the next view
The view sends the HTTP response back to the client/browser (retrieving any data required to render the view from the view helper)
Copyright Michael Campbell Associates Ltd. 1999-2003.
All Rights Reserved