ExecutableUsecaseResource
ExecutableUsecaseResource is a base class for resources providing a stateless usecase. you can extend this class if you want to develop a resource-type which will display several views for a usecase.It already has implemented a bunch of nice thing which you could like. e.g. Jelly (Executable XML), a standard executable usecase (default, done, cancel), custom usecases, Info and Error Messages.
At the moment folowing resource-types extending ExecutableUsecaseResource: user-mgmt.
ExecutableUsecaseResource extends BasicXMLResource
Since ExecutableUsecaseResource extends BasicXMLResource you can use all the things provided by BasicXMLResource.
Custom Resource Configuration (ConfigurableViewDescriptor)
Element Name |
Child-Element | Attribut | Explanation |
---|---|---|---|
views | view | Container for all views | |
view | mime-type, xslt, template, url, http-headers, serializer |
id, type | A single view. id can be 'default' or 'source' for built in views. Or any other id for a custom view. A view is accessed via id through a request parameter yanel.resource.viewid type can be xml, jelly, redirect (implementation not finished yet), custom. Default is xml. |
mime-type | - | E.g. text/html, application/xhtml+xml ... | |
xslt | - | Path to xslt. absolute data-repo path, rthdocs path, file path. see: Protocol-Schemas used configure xslt via ConfigurableViewDescriptor
|
|
template | - | Only useful when using type="jelly" | |
url | - | Only useful when using type="redirect" (implementation not finished yet) | |
http-headers | name, value | Define some http-headers for this view. | |
name | - | Name of the header-field | |
value | - | Value of the header-field | |
serializer | omit-xml-declaration, indent, doctype-public, doctype-system | key | If no serializer is specified for a view, the serializer will be chosen
depending on the mime-type, whereas the default serializer is XHTML_STRICT Possible Serializers (key): HTML_TRANSITIONAL, XHTML_STRICT, XML, TEXT |
omit-xml-declaration | - | Can be 'yes' or 'no' | |
doctype-public | - | Public Doctype e.g -//W3C//DTD XHTML 1.0 Transitional//EN | |
doctype-system | - | System Doctype e.g. http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd | |
indent | - | Can be 'yes' or 'no' |
Example
<views><view id="default" type="jelly">
<template>/jelly/default.jelly</template>
<xslt>/xslt/defaultr.xsl</xslt>
<xslt>/xslt/global.xsl</xslt>
</view>
<view id="done" type="jelly">
<template>/jelly/done.jelly</template>
<xslt>/xslt/done.xsl</xslt>
<xslt>/xslt/global.xsl</xslt>
</view>
<view id="cancel" type="jelly">
<template>/jelly/cancel.jelly</template>
<xslt>/xslt/cancel.xsl</xslt>
<xslt>/xslt/global.xsl</xslt>
</view>
<view id="tree" type="custom"/>
</views>
Jelly
If you extend from ExecutableUsecaseResource or UsecaseResource you can use jelly-views. see http://commons.apache.org/jelly/ for more details on jelly.
IMPORTANT: don't program logic within your jelly-template. Just use getters and setters to send and recieve data from/to your resource java class. If you implement logic within your jelly-template you will violate the model-view-controler pattern.
Jelly represents the view not the controler!
Built-in Jelly variables
Variable-name | Explanation: |
---|---|
resource | the current resource object |
yanel.back2context | Path prefix for yanel root. |
yanel.back2realm | Path prefix for realm root. |
yanel.globalHtdocsPath | Path prefix for accessing content from globalHtocsPath. |
yanel.resourcesHtdocsPath | Path prefix for accessing content of this resources HtdocsPath. |
yanel.reservedPrefix | Reserved Prefix of yanel. |
The standard executable usecase
The standard executable usecase works as follows:
- display the "default" view. this view has a form with a submit button and a cancel button.
-
if the user clicks submit, the checkPreconditions() method is executed.
- if there are any errors, the "default" view is displayed again, showing the error messages.
-
if everything is ok, the execute() method is called
- display the "done" view
- if the user cancels, call the cancel() method and then show the "cancel" view.
Your comments are much appreciated
Is the content of this page unclear or you think it could be improved? Please add a comment and we will try to improve it accordingly.