Kauri Documentation
 PreviousHomeNext 
5.1.9 Editing entities: Kauri FormsBook Index5.2 Prototyping: how it works

5.1.10 From prototype to real application, and back again

Up to now we have been running Kauri in prototype mode. If you want to stop working in prototype mode, simply don't pass the "-p prototype" argument.

5.1.10.1 From DB Mock to real data resources

Some things will then however be broken, especially all templates where you load data from DB Mock, since DB Mock is only available in prototype mode. You will have to replace the mock 'data' service by a real one. The way this works is that some Spring configuration is loaded based upon the runtime mode:

module1/src/main/kauri/spring/[prototype|production]

With the project generated by the prototyping-archetype, there is one sample entity present ("Person") which works in both modes. It makes use of JPA for the real entity, backed by an in-memory HSQLDB.

5.1.10.2 From direct template execution to resource classes

During prototyping, the templates in the "pages" directory are executed directly, without first going through some resource class (somewhat similar to what other frameworks call controller).

For some pages this is fine, and can stay this way. However, the more common way of working is to first perform logic and gather data in a resource class, which is then passed on to a template. In a resource class, it is easy to take decisions such as producing an error, redirecting to somewhere else, and so on. A template on the other hand directly starts producing output (and thus sending it to the browser), and hence does not allow to make such decisions anymore.

The same template file can however be reused. You do not need to copy it to another location or so: you can literally reuse the same file. When not in prototyping, the request routing will first look for resource classes to handle the request, before resorting to the direct execution of the templates in the pages directory (in prototyping mode, it works just the other way around).

There is one trick involved though. During prototyping, we define variables with the 'src' attribute to load data. When not prototyping, this data will be passed on from the resource class. Therefore we need to tell the variable not to overwrite the data if is is already previously defined, using the overwrite attribute:

<t:variable name="order" src="service:/data/orders/${id}" overwrite="false"/>

Again, the prototyping-archetype generated an example of this, see the PersonResource class.

5.1.10.3 Switch between prototype and production mode at any time

Since the same template files can be used for prototype and production mode, you can switch between them at any time.

 PreviousHomeNext 
5.1.9 Editing entities: Kauri Forms5.2 Prototyping: how it works