A page flow is usually defined in a file called
page-flow.xmlstored at the root of your Orbeon Forms resources. This XML file has a root element called
<controller>, which has to be within the
http://www.orbeon.com/oxf/controllernamespace. All the XML elements in a page flow have to be in that namespace unless stated otherwise. You start a page flow document as follows:
You can configure the location of the page flow configuration file in the web application's
web.xmlfile. See Packaging and Deployment for more information. In most cases, it is not necessary to change the default name and location.
Most web applications consist of a set of pages, identified to clients (web browsers) by a certain URL, for example:
In most cases the URL can be split as follows:
http://www.orbeon.org/identifies the web or application server hosting the application.
/myappmay optionally identify the particular web application running on that server. Whils this part of the URL path is not mandatory, its use is encouraged on Java application servers, where it is called the context path.
/report/detailidentifies the particular page within the web application. Such a path may be "flat", or hierarchical, separated with "/" (slashes).
?first=12&count=10specifies an optional query string which identifies zero or more parameters passed to that page. Each parameter has a value. This example has two parameters: the first one is called
12, and the second one is called
#middleis an optional fragment identifier identifying a section of the resulting page. Usually, this part of the URL is not handled by the web application, instead the web browser uses it to scroll to a section of the resulting page identified by this identifier (here
For a particular web application, what usually matters in order to identify a particular page is the path within the URL under the context path, here
/report/detail. Therefore, in an Orbeon Forms page flow, each page is identified with a unique path information. You declare a minimal page like this:
Other pages may be declared as follows:
In addition to pages, web applications also often consist of services. A service is not unlike a page, but it is usually consumed by software rather than a human being.
<service>element denotes a service:
- It clearly indicates that we are dealing with a service.
- It sets different defaults for authentication and authorization.
By default, pages can be accessed by the outside world. Of course, it is possible to protect them by an authentication and authorization mechanism. But, in general, the intent of a page is to be accessible from a web browser, at least for certain users.
On the other hand, by default, a service can only be accessed by an Orbeon Forms application and not from the outside world. This means that services are more secure. This makes sense because in many cases services exposed by Orbeon Forms are intended for consumption by Orbeon Forms applications themselves.
NOTE: In previous versions of Orbeon Forms, services were implemented using the
Creating a static page with Orbeon Forms is quite easy: just add a
viewattribute on a
<page>element which points to an XHTML file:
Here, using the
oxf:protocol means that the file is searched through the Orbeon Forms resource manager sandbox. It is also possible to use relative paths, for example:
The path is relative to the location of the page flow configuration file where the
<page>element is contained. Here is an example of the content of
<xh:title>Hello World Classic</xh:title>
It is recommended to to use XHTML and to put all the elements in the XHTML namespace,
http://www.w3.org/1999/xhtml. This can be done by using default namespace declaration on the root element (
xmlns="http://www.w3.org/1999/xhtml) or by mapping the namespace to a prefix such as
xhtmland to use that prefix throughout the document, as shown above. The file must contain well-formed XML: just using a legacy HTML file won't work without some adjustments, usually minor.
Instead of using a static XHTML page, you can also use an XSLT template to generate a dynamic page. This allows using XSLT constructs mixed with XHTML constructs, for example:
<p>The time is now <xsl:value-of select="current-dateTime()"/>!</p>
When XSLT templates are used, it is recommended to use the
In the MVC architecture, the page logic is implemented by a page model, and the page layout by a page view. The MVC architecture promotes the separation of model, view and controller:
- The page model is responsible for calling or implementing the business logic. It is in charge of gathering the information to be displayed by the page view.
- The page view is in charge of presenting to the user the information gathered by the page model. The page view usually produces XHTML and XForms, but it can also produce other results such as XSL-FO, RSS, etc. Handling of the output of the view is done in the page flow epilogue, which by default knows how to handle XHTML, XForms, XSL-FO, and custom XML document.
- The controller is responsible for dispatching a request from a client such as a web browser to the appropriate page model and view and connecting the model with the view. In Orbeon Forms, the controller is the PFC itself, which is configured with a page flow.
For instance, a news page can use a page model to retrieve the list of headlines and then pass this information as an XML document to a page view. The view produces an XHTML page by creating a table with the content of the headlines, adding a logo at the top of the page, a copyright notice at the bottom, etc.
<page>element therefore supports attributes defining what page model and page view must be used:
modelattribute is a URL refering to an XPL pipeline (optionally an XSLT stylesheet or a static XML file) implementing the model.
viewattribute is a URL refering to an XSLT stylesheet (optionally an XPL pipeline or a static XML file) implementing the view.
The model passes data to the view as an XML document, as follows:
- XSLT model. The model document is the default output of the XSLT transformation.
- Static XML model. The model document is the static XML document specified.
- XPL view. The model document is available on an input named
- XSLT view. The model document is available as the default input of the XSLT transformation.
- Static XML view. In this case, no model document is available to the view.
Here, the location of the model and view definitions mirrors the path of the page, and file names repeat the directory path, so that files can be searched easier. It is up to the developer to choose a naming convention, but it is recommended to follow a consistent naming structure. Other possibilities include:
A typical XSLT view can extract model data passed to it automatically by the PFC on its default input, for example, if the model generates a document containing the following:
Then an XSLT view can display the content of the
<name>element as follows:
<title>Hello World MVC</title>
<p>Hello <xsl:value-of select="/employee/name"/>!</p>