How it works: Module outcomes

Guara uses a special object, called Outcome, to convey the execution result from a Module. Outcomes may be returned from all methods executed by Modules.

The Outcome object holds enough information to determine which template the RenderScreen valve should render. The code, module and method are matched to determine the template name. Is there is no match, the default template is returned

If there is not outcome, or outcome is Outcome.UNKNOWN, the template set o RunData is used.

Example configuration:

<templateMapping> <module name="test.ActionTest"> <outcome code="SUCCESS" template="test.outcome.Success"/> <outcome code="SUCCESS" method="doX" template="test.outcome.SuccessWhenDoX"/> <outcome code="ERROR" template="test.outcome.Error"/> <outcome code="MyCode" template="test.outcome.MyTemplate"/> <outcome template="test.outcome.Default"/> </module> </templateMapping>

There are three reserved codes:


Outcome CodeMethod NameTemplate Rendered
UNKNOWNn/atemplate defined on RunData
every other coden/ascreens/test/outcome/Default.vm


The nice thing about this approach is that the user may configure the same valve (RenderScreen) with different template mappings on different pipelines.

This should enable the programmer to reuse the same action Module and send different types of content without having to hard code this logic on the module. (Example: hole page using the default pipeline or just a chunck using the ajax pipeline)