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']}"
action="copyDepartment"
id="DepartmentsCopyButton">
</af:commandButton>
Generated by the velocity template :
<af:commandButton textAndAccessKey="${JHS.nls ("Copy button"
,"COPY_BUTTON_LABEL_${JHS.current.group.name}"
,"Make a copy of this ${JHS.current.group.displayTitleSingular}" )}"
action="copyDepartment"
id="${JHS.current.group.name}CopyButton">
</af:commandButton>
And the manual added the navigationRule in the faces-config.xml looks like :
<navigation-rule>
<from-view-id>/pages/Departments.jspx</from-view-id>
<navigation-case>
<from-outcome>copyDepartment</from-outcome>
<to-view-id>/pages/DepartmentsTable.jspx</to-view-id>
</navigation-case>
</navigation-rule>
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 :
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”)}”.
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 http://download.oracle.com/consulting/jhsdevguide1013.pdf? 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
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’.
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)
thanks,.
Lucas