1 / 22

Using ADF Struts Components

Learn how to customize data actions and data pages, access business services, and enhance application behavior with Oracle ADF Struts components.

carolined
Download Presentation

Using ADF Struts Components

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Using ADF Struts Components

  2. 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. 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. 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. 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. Creating Data Pages • Drag a data page to the Page Flow Diagram. • /browseCustomer • The struts-config.xml file is updated with the data action. <action-mappings> <action path="/browseCustomers" className="oracle.adf.controller.struts.actions.DataActionMapping" type="oracle.adf.controller.struts.actions.DataForwardAction" name="DataForm" parameter="unknown"/> </action-mappings>

  7. Creating the View Component • Double-click the data page to create the view component. • /browseCustomer <action-mappings> <action path="/browseCustomers" className="oracle.adf.controller.struts.actions.DataActionMapping" type="oracle.adf.controller.struts.actions.DataForwardAction" name="DataForm" parameter="/browseCustomers.jsp"> <set-property property="modelReference" value="browseCustomersUIModel"/> </action></action-mappings>

  8. 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. Displaying Data • Select elements from the Data Control Palette and drag them to the page: Generated code <c:forEach var="Row" items="${bindings.CustomersView1.rangeSet}"> <tr><td> <c:out value="${Row.CustomerId}"> </c:out></td>…

  10. 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. Adding Methods to Data Actions • To perform DML with data actions, add methods to the data action: Drag to data page icon • /browseCustomer • /addCustomer <action path="/addCustomers" … <set-property property="methodName" value="addCustomersUIModel.Create"/> </action>

  12. Adding Methods to Data Pages • Drag and drop methods from the Data Control Palette to add methods to a data page: Create setCurrentRowWithKey Delete

  13. 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. Data Action Life Cycle 1. Initialize context Get HTTP request Get binding info 2. Build event list 8. Invoke custom methods 3. Check for model bindings 9. Refresh binding controls 4. Check if updates allowed 10. Dispatch to forward 5. Process updates 6. Validate updates 7. Handle model and UI events

  15. 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) { … }

  16. 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_<operation>”, for example, event_Commit. • Hyperlink with a parameter “event=< operation>”, for example, event=Commit.

  17. Data Action Events • Using built-in events, you can define your own operations: • Defined by: • Coding an on<CustEvent>() method in the data action • Invoked by: • Button with the name “event_<CustEvent>”, for example, event_Help. • Button with the name “event” and value <CustEvent>,for example, name=“event” value=“Help”. • Hyperlink with a parameter event=< operation>, for example, event=Commit.

  18. on<Event> Example: Built-in Events • Extending a named built-in event ?event=commit public void onCommit(DataActionContext ctx) { HttpSession session = ctx.getHttpServletRequest().getSession(); Boolean loggedOn = (Boolean)session.getAttribute("AUTHFLAG"); if (loggedOn.booleanValue()) { ctx.getEventActionBinding().doIt(); } }

  19. on<Event> Example: Custom Events • Calling a custom operation event=foo public void onFoo(DataActionContext ctx) { // just direct the flow to the "foo" forward ctx.setActionForward("foo"); }

  20. 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: … <html:form action="/addCustomers.do"> … <input name="event_Add" type="submit" value="Submit"/> …

  21. 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

  22. Practice 12-1: Overview • This practice covers the following topics: • Creating data actions • Adding methods to data actions

More Related