Presentation is loading. Please wait.

Presentation is loading. Please wait.

12 Copyright © 2004, Oracle. All rights reserved. Using ADF Struts Components.

Similar presentations


Presentation on theme: "12 Copyright © 2004, Oracle. All rights reserved. Using ADF Struts Components."— Presentation transcript:

1 12 Copyright © 2004, Oracle. All rights reserved. Using ADF Struts Components

2 12-2 Copyright © 2004, Oracle. All rights reserved. Objectives After completing this lesson, you should be able to do the following: Describe data actions and data pages Customize data actions and data pages to enhance the behavior of an application Use data actions to access multiple types of business services Describe the relationship between databound pages and data pages

3 12-3 Copyright © 2004, Oracle. All rights reserved. What Are Data Actions? Data actions are an extension of the action class, which: Are provided with Oracle ADF Provide access to business services, such as business components Prepare the data and make it available for pages to consume

4 12-4 Copyright © 2004, Oracle. All rights reserved. What Are Data Pages? Data pages are an extension of the DataAction class, which: Are provided with Oracle ADF Combine a data action and a page forward Do not rely on forwards to forward application data Simplify the Page Flow Diagram

5 12-5 Copyright © 2004, Oracle. All rights reserved. Utilizing Data Pages To use a data page, perform these steps: 1.Create the data page in the Page Flow Diagram. 2.Double-click to create the corresponding view object (JSP, HTML, and UIX). 3.Define the Struts page flow as necessary. 4.Add business service methods to the data page as necessary.

6 12-6 Copyright © 2004, Oracle. All rights reserved. Creating Data Pages <action path="/browseCustomers" className="oracle.adf.controller.struts.actions.DataActio nMapping" type="oracle.adf.controller.struts.actions.DataForwardAct ion" name="DataForm" parameter="unknown"/> Drag a data page to the Page Flow Diagram. The struts- config.xml file is updated with the data action. /browseCustomer

7 12-7 Copyright © 2004, Oracle. All rights reserved. Creating the View Component Double-click the data page to create the view component. <action path="/browseCustomers" className="oracle.adf.controller.struts.actions.DataActio nMapping" type="oracle.adf.controller.struts.actions.DataForwardAct ion" name="DataForm" parameter="/browseCustomers.jsp"> <set-property property="modelReference" value="browseCustomersUIModel"/> /browseCustomer

8 12-8 Copyright © 2004, Oracle. All rights reserved. Displaying Data To display data from the data page, add elements from the Data Control Palette: Bound Data Navigation Operations The data controls associated with the data action are defined in DataBindings.cpx (created automatically).

9 12-9 Copyright © 2004, Oracle. All rights reserved. Displaying Data Select elements from the Data Control Palette and drag them to the page: <c:forEach var="Row" items="${bindings.CustomersView1.range Set}"> … Generated code

10 12-10 Copyright © 2004, Oracle. All rights reserved. Modifying the Iterator Click the UIModel icon in the Structure pane to locate the iterator for the model. Then use the Property Inspector to change the range size.

11 12-11 Copyright © 2004, Oracle. All rights reserved. <action path="/addCustomers" … <set-property property="methodName" value="addCustomersUIModel.Create"/> Adding Methods to Data Actions To perform DML with data actions, add methods to the data action: Drag to data page icon /browseCustomer/addCustomer

12 12-12 Copyright © 2004, Oracle. All rights reserved. Adding Methods to Data Pages Drag and drop methods from the Data Control Palette to add methods to a data page: setCurrentRowWithKey Delete Create

13 12-13 Copyright © 2004, Oracle. All rights reserved. Navigating in Data Pages HTML Form tag submits to itself, by default. Change the action to the page that receives the form data. Use the Property Inspector to change the value of “action.” Select the data page or action that receives the form data.

14 12-14 Copyright © 2004, Oracle. All rights reserved. Data Action Life Cycle 1. Initialize context Get HTTP request Get binding info 2. Build event list 3. Check for model bindings 4. Check if updates allowed 5. Process updates 6. Validate updates 7. Handle model and UI events 8. Invoke custom methods 9. Refresh binding controls 10. Dispatch to forward

15 12-15 Copyright © 2004, Oracle. All rights reserved. The Data Action Lifecycle 1. Initialize Context Get HTTP Request Get Binding Info 2. Build event list 3. Check for model bindings 4. Check if updates allowed 5. Process Updates 6. Validate Updates 7. Handle Model and UI events 8. Invoke Custom Methods 9. Refresh binding controls 10. Dispatch to forward

16 12-16 Copyright © 2004, Oracle. All rights reserved. Customizing Data Actions Data action methods may be customized to provide functionality for: A data action having two possible forwards: Any custom functionality: protected ActionForward findForward(…) { Object s = request.getParameter("Update"); if (s != null) { return getActionMapping().findForward("success"); } else return getActionMapping().findForward("browse"); } Protected void invokeCustomMethod(DataActionContext ac) { … }

17 12-17 Copyright © 2004, Oracle. All rights reserved. Data Action Events Built-in operations are listed in the UIModel.xml file: Defined by: –Dragging operation from the Data Control Palette –Explicit creation in the Structure pane Invoked by: –Button with the name “event_ ”, for example, event_Commit. –Hyperlink with a parameter “event= ”, for example, event=Commit.

18 12-18 Copyright © 2004, Oracle. All rights reserved. Data Action Events Using built-in events, you can define your own operations: Defined by: –Coding an on () method in the data action Invoked by: –Button with the name “event_ ”, for example, event_Help. –Button with the name “event” and value, for example, name=“event” value=“Help”. –Hyperlink with a parameter event=, for example, event=Commit.

19 12-19 Copyright © 2004, Oracle. All rights reserved. on Example: Built-in Events Extending a named built-in event public void onCommit(DataActionContext ctx) { HttpSession session = ctx.getHttpServletRequest().getSession(); Boolean loggedOn = (Boolean)session.getAttribute("AUTHFLAG"); if (loggedOn.booleanValue()) { ctx.getEventActionBinding().doIt(); } ?event=commit

20 12-20 Copyright © 2004, Oracle. All rights reserved. on Example: Custom Events Calling a custom operation public void onFoo(DataActionContext ctx) { // just direct the flow to the "foo" forward ctx.setActionForward("foo"); } event=foo

21 12-21 Copyright © 2004, Oracle. All rights reserved. Forwards and Events in ADF Applications Name related forward components the same as the submit buttons to submit first to the data page, then to the forward target. addCustomers.jsp : … … …

22 12-22 Copyright © 2004, Oracle. All rights reserved. Summary In this lesson, you should have learned how to: Create data pages mapped to business services Create Web applications that utilize data pages Customize data actions and data pages to enhance the behavior of an application

23 12-23 Copyright © 2004, Oracle. All rights reserved. Practice 12-1: Overview This practice covers the following topics: Creating data actions Adding methods to data actions

24 12-24 Copyright © 2004, Oracle. All rights reserved. Practice 12-1

25 12-25 Copyright © 2004, Oracle. All rights reserved. Practice 12-1

26 12-26 Copyright © 2004, Oracle. All rights reserved. Practice 12-1

27 12-27 Copyright © 2004, Oracle. All rights reserved. Practice 12-1

28 12-28 Copyright © 2004, Oracle. All rights reserved. Practice 12-1

29 12-29 Copyright © 2004, Oracle. All rights reserved. Practice 12-1

30 12-30 Copyright © 2004, Oracle. All rights reserved. Practice 12-1

31 12-31 Copyright © 2004, Oracle. All rights reserved. Practice 12-1

32 12-32 Copyright © 2004, Oracle. All rights reserved. Practice 12-1

33 12-33 Copyright © 2004, Oracle. All rights reserved. Practice 12-1

34 12-34 Copyright © 2004, Oracle. All rights reserved.


Download ppt "12 Copyright © 2004, Oracle. All rights reserved. Using ADF Struts Components."

Similar presentations


Ads by Google