Supplying Method Parameters for an ADF Method Invocation

When you want to work with a method return in the Data Control Palette, the method execution will not utilize the ADF iterator binding. Normally, you can drop the method return onto your document or data page and the ADF lifecycle will handle the method execution implicitly (without an iterator binding). However, when the method return takes parameter values, you must perform a preliminary step to bind the parameter values to the method before it is invoked. The following procedures describe alteratives, where the first is recommended as a best practice.

To use the page flow to prepare the method before executing:

  1. Open the page flow diagram and insert a data action (DA1) and a data page (DP1), and draw a forward transition between the two.

    Page flow displays seperate data action and data page.

  2. Using the Data Control Palette, drop the method return node that contains the parameters you wish to prepare on to the data action.

  3. Create the web page for the data page (DP1) to render the data from the method return.

  4. Return to the page flow and view the completed page flow diagram .

    Data page is complete.

  5. Click the Source tab for the page flow and locate the modelReference property for the data action (DA1) and change the value so the name no longer matches the UI model of the page used to render the result (DP1UIModel):

    
    	
    
      <action path="/DA1" className="oracle.adf.controller.struts.actions.DataActionMapping" 
    
                            type="oracle.adf.controller.struts.actions.DataAction" name="DataForm">
    
              <set-property property="modelReference" value="DA1UIModel"/>
    
              <forward name="success" path="/DP1.do"/>
    
         </action>        

    This step allows the parameter binding to occur without relying on a method iterator.

The above procedure permits the page flow to bind the parameters to the method before it is invoked. However, if you do not wish to use a separate data action and data page for this purpose, you can instead, override the prepareModel() method in the data action or data page. The result will be the same, the prepareModel() method call will bind the method parameters before the method invocation is performed.

To subclass a data page or data action for prepareModel():

  1. To create the subclass, right-click the data page or data action in the page flow diagram and choose Go to code.

  2. In the dialog, the Extends field identifies the super class oracle.adf.controller.struts.actions.DataAction or oracle.adf.controller.struts.actions.DataForwardAction. Accept the default values and click OK.

    The design time adds the class file to your project and opens the file in the Java Code Editor.

  3. In the toolbar choose Tools | O verride Methods to open the Override Methods dialog.

  4. In the Override Methods dialog select prepareModel(DataActionContext):void.

  5. Implement the prepareModel() method in the Java Code Editor and save the subclass.

    
    
    
    protected void prepareModel(DataActionContext actionContext) throws Exception 
    
      { 
    
          Long  rowCount = new Long(20); 
    
      
    
          Integer rangeSize = new Integer(3); 
    
          BindingContext p0 = actionContext.getBindingContext(); 
    
          if (p0.containsKey("rangeSize")) 
    
          p0.remove("rangeSize"); 
    
        
    
          p0.put("rangeSize", rangeSize); 
    
          if (p0.containsKey("rowCount")) 
    
            p0.remove("rowCount"); 
    
        
    
          p0.put("rowCount", rowCount); 
    
          super.prepareModel(actionContext); 
    
      }        

Inserting Business Service Method Results Using the Data Control Palette

Inserting Business Service Actions Using the Data Control Palette
Supplying Method Parameters for an Action Binding

 

Copyright © 1997, 2004, Oracle. All rights reserved.