Wednesday, 2 April 2008

JDev 11g - Task Flows - Wildcard Control Flow Rules

The JSF page diagrammer introduced within JDeveloper 10.1.3 was a great addition to the tool allowing programmers to see visually the flow between different pages in a JSF application. Tools like Oracle Forms and Apex having nothing to compare and another reason why JDeveloper is my tool of choice.

However there was a minor oversight in JDev 10.1.3 release's JSF page navigation diagrammer in the fact it didn't have a diagrammatic representation of wildcard navigation rules.

The JSF specification allows simple navigation rules defined between one page and another, and also wildcard navigation rules allowing navigation from any page matching a wildcard expression to another page.

For example wildcard navigation rules are particular useful when defining navigation to a single Login page. Potentially every page in the application will have a Login link at the top right of the page to allow the user to navigate to the Login page and login to our application. However it would be a painful exercise to have to define individual navigation rules from all these page to the Login page in our JSF page navigation diagrammer. Instead we make use of a wildcard navigation rule to cut down our work.

Within the faces-config.xml file a simple page-to-page navigation rule could look as follows:

<navigation-rule>
  <from-view-id>/onePage.jspx</from-view-id>
  <navigation-case>
    <from-outcome>goToAnotherPage</from-outcome>
    <to-view-id>/anotherPage.jspx</to-view-id>
  </navigation-case>
</navigation-rule>


As such you can navigate from onePage to anotherPage through the named navigation rule goToAnotherPage.

A resulting JSF page navigation diagram would look as follows:


A wildcard navigation rule could look as follows:

<navigation-rule>
  <from-view-id>*</from-view-id>
    <navigation-case>
    <from-outcome>goToLoginPage</from-outcome>
    <to-view-id>/login.jspx</to-view-id>
  </navigation-case>
</navigation-rule>


As such any page can navigate to the login.jspx page through the named navigation rule goToLoginPage.

You'll note the * within the <from-view-id> tag representing the wildcard expression. This can be more restrictive including directory names and other page names. For instance if only pages within the bookings subdirectory can access the login page, the following rule would apply:

<navigation-rule>
  <from-view-id>bookings/*</from-view-id>
  <navigation-case>
    <from-outcome>goToLoginPage</from-outcome>
    <to-view-id>/login.jspx</to-view-id>
  </navigation-case>
</navigation-rule>


However the resulting JSF page navigation diagram within JDeveloper 10.1.3 has no ability to visual show this navigation rule:


As you can imagine a diagrammatic representation of page flows that is missing navigation rules can be a minor headache for new programmers not knowing to look in the faces-config.xml file.

This minor oversight is corrected in the upcoming JDev 11g release, with the introduction of the Wildcard Control Flow Rule in the new Task Flow diagrammer:


By dragging and dropping a Wildcard Control Flow from the Control Palette, it gives you the ability to diagrammatically define the wildcard entry point and create appropriately named navigation rules (called Task Flow Calls in 11g) to the destination page. Taking our Login example from previous we end up with the following diagram:


Note the Wildcard Control Flow element in the top left.

While there has been a huge array of totally new features in 11g, there have also been minor fixes and extensions of existing features to fill them out and make them more complete. This particular change among many shows a tool moving into a more mature mode, addressing criticisms of JDeveloper's immaturity in the past.

No comments: