Generate jsf navigationrules with JHeadstart

Aino Andriessen 3

The templating mechanism of JHeadstart is a huge improvement over the previous versions. It is now quite easy to add your postgeneration changes to a velocity template and add it to the generation again: no more postgeneration. But there are a few things to be aware of : 1. postgeneration to the pagedefinition cannot be templated 2. take care of your custom nls generated text, as described in an earlier post and 3. custom navigation rules cannot be generated…

…or can they?

For navigation to another page you can rely on the existing navigationrules that are defined (actually generated) in the faces-config.xml, but it may be better to introduce your own. For example when you want to return to the overview (table) page after you made a copy of the current Department.

The commandButton would look like this (I’ll leave out the actionListener that performs the actual method) :

<af:commandButton textAndAccessKey="#{nls['COPY_BUTTON_LABEL_DEPARTMENTS']}"

Generated by the velocity template :

<af:commandButton textAndAccessKey="${JHS.nls ("Copy button"
                                              ,"Make a copy of this ${}" )}"

And the manual added the navigationRule in the faces-config.xml looks like :


However, after generation, the rule is gone and must be added again. By the way, using the history of a file makes it really easy to add it again :The design editor shows the difference between two versions


It would be much easier if we could include this rule in the generation process. One option is to add the rule to the faces-config.vm template. But we have now made additions to two templates that we have to maintain. It may be better if could somehow combine the action and the navigationrule in one template. This can be accomplished with the JHeadstart application generator method addGlobalNavigationCase and use that in our template, the action now looks like :

action=”${JHS.facesConfigGenerator.addGlobalNavigationCase(“CopyDepartment”, “DepartmentsTable”)}”

This method creates the global navigation (actually it adds it to the stack so that its generated later in the generation process) and returns the from-outcome. If you don’t like the global navigationcase, use the addNavigationCase method :


action=”${JHS.facesConfigGenerator.addNavigationCase(“Department”, “CopyDepartment”, “DepartmentsTable”)}”.


3 thoughts on “Generate jsf navigationrules with JHeadstart

  1. Aino, good explanation!

    Did you know that the feature of generating navigation rules is also described in the JHeadstart Developer’s Guide of October 2006 at See chapter 3 – JHeadstart Application Generator – Customizing Page Layout Generation – Using Generator Templates – Generating a JSF Navigation Rule from a Generator Template.

    There is also a section about Generating a JSF Managed Bean from a Generator Template.

    kind regards, Sandra

  2. You can view the local (i.e. JDeveloper) history of a file on the History tab, underneath the file, next to the Design and Source tab. It can be configured (only a bit) with ‘preferences -> Environment -> Local History’.

  3. Very good post! Shows the power of the JHeadstart templating mechanism, and your command of taking it to the limits.

    (by the way, how do you get the history of files to be available)



Comments are closed.

Next Post

A session you must attend - How to best achieve High Availability for Oracle Databases with Carel-Jan Engel and Jeroen Evers

As you can see in the announcement on the top of this page – tomorrow we will host the most exciting DBA event of the year: the AMIS Query on High Availability for Oracle Databases, presented by Carel-Jan Engel and Jeroen Evers, both members of the renowned Oak Table Network. […]
%d bloggers like this: