Workflow is the main component of the whole framework.
Workflow is initialized through XML file written according to DTD, which is available at
http://www.ais.pl/dtds/workflow_0_2.dtd.
Public ID for this file is -//AIS.PL//DTD Workflow Description 0.2//EN
.
Workflow consists of a set of 'Page' objects. Every Page is configured in XML with following attributes:
name
- identifies the given page across the Workflow set of pages;class
- name of a class which represents the 'Page', this class
must be a concrete, non-abstract subclass of pl.aislib.fm.Page
abstract class;template
- key for TemplateEngine, specifies the template used for
generating response from page.session-expiration
- indicates whether page can be displayed when there
is a new HTTP session. Possible values: true
(default) - flow will be
redirected to start page; false
- page can be displayed when the HTTP
session is new. This attribute is considered only if attribute
session-expiration-check
of the workflow object is set to 'isNew'.Every page may have triggers in their configuration. Triggers are responsible for moving application from one page to another. Definition of trigger consists of following attributes:
name
- name of trigger;page-ref
- name of page we want to move to;predicate
- full name of class implementing org.apache.commons.collections.Predicate
;type
- type of trigger, defines scope of trigger;name
and page-ref
are required.
type
attribite is optional and specify, what exactly should be checked.
Following values are possible for type
attribute:
request-param
- default value, trigger will check request
parameter with name specified by name
attribute;request-attr
- trigger will check request attribute
with name specified by name
attribute;session-attr
- trigger will check session attribute
with name specified by name
attribute;request
- trigger will check whole request, name
attribute is ignored in this case;predicate
is optional. This attribute specify
full name of class implementing org.apache.commons.collections.Predicate
(note that specified class must have non-argument constructor).
During trigger evaluation value specified by type
attribute
(and in case of request-param
, request-attr
, session-attr
name of attribute) is passed to evaluate(Object)
method and,
if method returns true, controller move execution to page
specified by page-ref
.Every page may have flows in their configuration. Flow entries
declare, that page may move execution to different page. Definition
of flow consist of two values: name
and page-ref
.
If page code during execution moves execution to page which is not
declared as flow, WARN
message is generated.
A set of pages may be configured to use one template container.
Template container represents the common look of HTML view of an
application, sometimes called 'main template'. Configuration of template
container consists of template-name
(key for template engine)
and slot
- specifies where in the 'main templare' output from
the page should be inserted.
Applicaton.dispatch
method uses the following algorithm for moving
servlet request and response to proper page and getting the response from page:
page
parameter in the request, if there is no
page
parameter index
value is used;name
,
PageNotFound error code is generated (404 error);Response from a page is encapsulated in the PageResponse class. PageResponse consists of content type and content. Content may be an array of bytes or Map instance. The following algorithm is used for performing response from the page:
Workflow contains two attributes:
start-page
- page which should be displayed after launching the application
(default 'index')session-expiration-check
- if set to 'isNew' then framework will check
before processing request if the HTTP session is new and if page has session-expiration
set to 'true' then start page will be displayed; if set to 'none' (default) then session expiration
will not be checked.Consider the following example of workflow configuration:
<!DOCTYPE workflow PUBLIC "-//AIS.PL//DTD Workflow Description 0.2//EN" "http://www.ais.pl/dtds/workflow_0_2.dtd"> <workflow start-page="index" session-expiration-check="isNew"> <page name="index" class="example.pages.Index" template="index.html" session-expiration="false"/> <page name="menu" class="example.pages.Menu" template="menu.html" session-expiration="false"> <trigger name="sale" page-ref="sale"/> </page> <page name="sale" class="example.pages.Sale" template="sale.html"/ session-expiration="true"/> </workflow>
action
parameter: response from Index
page;action=index
: response from Index
page;action=menu
, no sale
parameter: response from Menu
page;action=menu
, sale
parameter is set: response from Sale
page.