8. Saving processor results

We have learned how to load parameters with fixed and dynamic values and we know from the process definition that results can be stored to the available stores.

To complete our knowledge about storing values we should have to look again at the part of the step definition where the processor result gets saved:

...

<save result="output" store=”output” key="welcomePage" presentable="true"/>

...

The result entry with the key output that is provided by the TemplateRender is stored to the output store using the key welcomePage. This is the key that enclosing processes can use to get the generated page in the same way as we have retrieved the formatted date from the DateFormatter by using the key output. If we would delete this line or comment it out, the outer world would not be able to retrieve the generated page. Just do it to see what happens:

...

<!- Disabling the following line by using xml comment
<save result="output" store=”output” key="welcomePage" presentable="true"/>
-->

...

If we upload this and reload the page we will see nothing. The page will be empty as Projector could not find any presentable result of the invoked processor. Instead of the rendered page we will see an entry in the Projector log file that indicates this failure:

> SEVERE: No presentable value found!

We don’t bother and want to start another experiment that will show us the power and simplicity of Projector by changing the step definition in the following way:

...
<save result="output" store=”output” key="welcomePage" presentable="true"/>
<save result="output" store=”repository” key="/files/welcomePage.html" presentable="true"/>
...

When you reload the web page you’ll see our beloved page again, as Projector is finding a presentable result. Now have a look at the WebDAV repository by opening the appropriate Webfolder or any other client of your choice. If you browse into the files directory you’ll see that Projector has saved the generated page to this folder:

In this example we have seen that it is possible to define multiple save directives to a single processor result. It would for sure be possible to store the generated page at different locations of the repository if needed.

The ability to store a processor result to the repository is very useful as it enables you to easily create some dynamic documents that are evaluated and stored into the repository afterwards. By using this trick it is easy to create applications like weblog or guestbook entries or any other structured content that needs to be generated from user input.