Java Reference
In-Depth Information
This binds the scripting variable to the outputText field. This also means that when the page is displayed, the
scripting variable value will be shown.
7.
Save UpdateEmp.
We will now define a navigation rule in GetEmp, then test that the empNum variable value is being set by GetEmp and
displayed by UpdateEmp.
Navigation rules
Navigation rules are defined for a component(s) and, in this case, the component is the Submit button on GetEmp.
A navigation rule dictates which resource to “go to” for the outcome of an action. You may be wondering, “What is an
action?” In a Facelet, an action is simply a method in the RAD-generated pagecode class. The method (i.e., the action)
is coded such that the method returns a string (i.e., an outcome), and the method name is doXXXAction, where XXX is
the visual component name.
The method-naming convention must be followed because this is how the server knows which method in the
pagecode class to execute when an event occurs to that visual component (e.g., the button is clicked). For instance,
to define a navigation rule for button1 (the Submit button), a method called doButton1Action must be defined in
the pagecode class. Inside of the doButton1Action method any Java statements can be entered; however, a return
statement must be coded to return a string value. This returned value is the outcome of the method/action. Different
outcome values (i.e., string values) can be returned based on the processing within the action (i.e., the method) and
there can be many navigation rules, each based on a different outcome value.
As you probably suspect, RAD makes defining a default action easy. Default actions return an empty string as an
outcome. (Yes, an empty string is a valid outcome!)
Tutorial: Defining a Navigation Rule
For this example, we will generate a success outcome and a single navigation rule.
1.
In the Page Designer, click on GetEmp's Submit button.
2.
Display the Properties View and scroll to the right to show the navigation rules table.
The Properties view should look like Figure 12-35 . Before defining the navigation rule, however, the action (i.e.,
the method in the pagecode class GetEmp.java) must be created. The programmer can go directly into GetEmp.java
and code the method, but RAD provides a much easier way to create the method.
Figure 12-35.
 
Search WWH ::




Custom Search