Sat. Dec 4th, 2021

Explanation: The Router activity is used to check for a condition and then direct the control to the appropriate flow. When we drag-and-drop the router component, the Router activity is added to the task low which has the following properties:

1. default-outcome: This determines the default outcome of the router.
2. expression: This is used to provide the expression that will be evaluated at runtime to determine which outcome has to be chosen for the flow. There can be many expression properties, but there will always be one default-outcome and it is mandatory to set the default outcome. The EL expression is used at design time to provide the expression. For example:

<expression>#{pageFlowScope.employweeBean.count == 1}</expression> <outcome>department</outcome>

If the count variable in employeeBean is evaluated to 1, then the control is taken to the department flow as outcome.

Requirement: I have a bounded task flow task-flow-definition.xml. In this task flow I have three view activities: view1, view2, and view3. Also I have one router named as router1. We have the following control flow cases as shown below:

  1. Control flow case gotoRouter from view1 to router1.
  2. Control flow case gotoPage1 from router1 to view2.
  3. Control flow case gotoPage2 from router1 to view3.
  4. Control flow case backFromPage1 from view2 to view1.
  5. Control flow case backFromPage2 from view3 to view1.

Double click each of these view activities to create the view1.jsff, view2.jsff, and view3.jsff.

In view1.jsff we have one inputText to enter User Name and one button named as Login. When user pass some User Name in the inputText and click on the Login button it will go to the router1 and based on the User Name we typed it will decide which view to be called (view2.jsff or view3.jsff).

Also in each of view.jsff and view3.jsff we will have one button to go back to the view.jsff. How to achieve this functionality.

Solution: For solution to the above requirement follow the steps as shown below:

Step 1: Create a New ADF Fusion Web Application named as RouterDemo.

Step 2: Create a bounded task flow task-flow-definition.xml. Inside the bounded task flow drag and drop three view activites: view1, view2, and view3 from the component palette. Double click each of these view activities to create the view1.jsff, view2.jsff, and view3.jsff.

Drag and drop router named as router1 in the bounded task flow from the component palette.

Also drag and drop the corresponding control flow cases as shown in the below diagram:

Step 3: Open view1.jsff and drag and drop one af:inputText. Label the af:inputText as User Name and create the binding for the af:inputText as binding=”#{pageFlowScope.MyBean.unameBinding}”

Please note we will not write any code in MyBean.java other then the af:inputText binding code which gets generated automatically.

Drag and drop one af:button and named the button as Login. Set te action of the af:button as action=”gotoRouter”.

Thus, the complete view.jsff code is shown below:

Step 4: Open view2.jsff and drag and drop one af:button and set the text and action as text=”Back button from Page1″ action=”backFromPage1″. Surround the button with af:panelGroupLayout.

Thus, the complete view2.jsff code is shown below

Step 5: Open view3.jsff and drag and drop one af:button and set the text and action as text=”Back button from Page2″ action=”backFromPage2″. Surround the button with af:panelGroupLayout.

Thus, the complete view3.jsff code is shown below

Step 6: Open task-flow-definition.xml and click on router1. Now set the following properties for the router1 as shown below:

Here, it is mandatory to give the default outcome. When the page run and if we type the User Name as Susanto then the view2.jsff is called. If we type User Name as Nilesh and click on Login then view3.jsff is called. If we don’t type any User Name and click on Login then by default view2.jsff is called.

Step 7: Create a launch.jspx page and drag and drop task-flow-definition.xml as a region on the launch.jspx page as shown below:

Step 8: Save all and run the launch.jspx. Thus, the ran application is shown below:

Here, if we don’t write any User Name and click on Login button then by default the view2.jsff is called. If we type User Name as Susanto and click on Login then view2.jsff is called as shown below:

On click of Back button from Page1 we get redirected to view1.jsff.

If we type User Name as Nilesh and click on Login then view3.jsff is called as shown below:

On click of Back button from Page2 we get redirected to view1.jsff.

Hence, the solution to our requirement.

If you like the post please comment, share, and do join me on Facebook. Please subscribe to my YouTube Channel for video tutorials.

Thanks & Regards,
Susanto Paul

 623 total views,  2 views today

By Susanto Paul

Susanto is an Oracle ACE, a qualified MCA, MBA, and a highly-skilled Senior Oracle Specialist. He is an enthusiastic Blogger and YouTuber who helps learners to solve their complex problems more efficiently. He has 9+ years of experience in multiple technologies like AWS, Oracle ADF, Oracle APEX, Oracle JET, Oracle VBCS, Oracle IDCS, Oracle PL/SQL, Oracle Integration Cloud, Java, JDBC, Servlets, JSP, Spring, Hibernate, HTML5, CSS3, JavaScript, TypeScript, NodesJS, Angular, MySQL, Oracle WebLogic Server, JUnit, JMeter, Selenium Web Driver, etc. He is a certified: Oracle Certified Professional Java SE 6 Programmer, Oracle ADF 11g Certified Implementation Specialist, Oracle Cloud Platform Application Integration 2020 Certified Specialist, Oracle Cloud Infrastructure Foundations 2020 Certified Associate, and Oracle Cloud Infrastructure Developer 2020 Certified Associate

Leave a Reply

Your email address will not be published. Required fields are marked *

satta king chart