Generate jsf navigationrules with JHeadstart

Aino Andriessen 3
0 0
Read Time:2 Minute, 11 Second

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 :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”)}”.

 

About Post Author

Aino Andriessen

Aino Andriessen is principal consultant and expertise lead 'Continuous Delivery'. His focus is on Oracle Fusion Middleware ADF and SOA development, Continuous Delivery, architecture, improving the software development proces and quality management. He is a frequent presenter at Oracle Open World, ODTUG Kaleidoscope, UKOUG Technology Conference and OUGN Vårseminar. He writes articles and publishes at the AMIS technology blog (http://technology.amis.nl/blog/).
Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

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 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

  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)

    thanks,.

    Lucas

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: