Programming-best practices( beginner) ADF_fusionapps
Upcoming SlideShare
Loading in...5
×
 

Programming-best practices( beginner) ADF_fusionapps

on

  • 1,012 views

Programming tips and tricks for ADP starters in Fusion Apps

Programming tips and tricks for ADP starters in Fusion Apps

Statistics

Views

Total Views
1,012
Views on SlideShare
1,012
Embed Views
0

Actions

Likes
1
Downloads
72
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Programming-best practices( beginner) ADF_fusionapps Programming-best practices( beginner) ADF_fusionapps Presentation Transcript

  • 1 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Oracle ADF Programming Best Practices for Beginners Frank Nimphius Senior Principal Product Manager Application Development Tools
  • Program Agenda  Simplify Your Development Choice  ADF Business Components  ADF Task Flow  ADF Binding  ADF Faces  JavaScript  Break Out Of Isolation 3 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Simplify Your Development Choice 4 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Simplify Your Technology Choice Choose a Development Approach Database Oriented Java EE Oriented SOA Oriented • EJB / JPA • Services  ADF Binding • ADF Binding • ADF Binding  ADF Task Flow • ADF Task Flow • ADF Task Flow  ADF Faces • ADF Faces • ADF Faces  Data Visualization • Data Visualization • Data Visualization  RDBMS  ADF BC 5 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Simplify Your Technology Choice Common Technologies Database Oriented Java EE Oriented SOA Oriented • EJB / JPA • Services  ADF Binding • ADF Binding • ADF Binding  ADF Task Flow • ADF Task Flow • ADF Task Flow  ADF Faces • ADF Faces • ADF Faces  Data Visualization • Data Visualization • Data Visualization  RDBMS  ADF BC 6 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • ADF Business Components 7 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • ADF Business Components Application Module Data Model View Object XML Definition References View Object Base Class XML Definition References AM Base Class 8 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 1 * Entity Object XML Definition References Entity Object Base Class
  • ADF Business Components Architecture Best Practices 9 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Use ADF Business Components Preferences 10 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Use ADF Business Components Preferences EntityImpl YourOrgEntityImpl YourAppEntityImpl 11 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Use ADF Business Components Preferences 12 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Use ADF Business Components Preferences 13 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • ADF Architecture Square http://bit.ly/adfarchsquare  Development – Oracle ADF Development Essentials – ADF Code Guidelines (v1.00) – ADF Naming and Project Layout Guidelines (v2.00) 14 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • ADF Business Components Implementation Best Practices 15 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • General Considerations Custom Framework Extension Classes  Always create and use custom base-classes for at least – ApplicationModuleImpl – EntiyImpl – ViewRowImpl – ViewObjectImpl  Note that creating custom super classes for <object>Def classes are less common 16 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Entity & View Object When to generate Java Impl files  Generate Java Impl files when entity objects are accessed from Java or Groovy  Ensure code that accesses entity objects directly uses type safe APIs instead of the generic framework APIs  Do not generate Impl classes without a need – Keep code base size reasonable. – Impl classes for the *def classes are rarely needed 17 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • View Criteria Prefer One View Object with Many View Criteria  Not necessary to create separate VO that only differ by their WHERE clause  Apply view criteria declaratively when defining view accessor and AM data model instances – Use bind variables with View Criteria – Be aware that "Ignore Null Values" options is of bad performance  Avoid direct user input in ADF BC queries to protect against SQL injection attacks 18 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Performance Tuning And Optimization Developers always strive for "better"  Premature optimizations as the root of all evil – Measure Performance, don't guess it. – If performance measures as bad, look for optimizations  Make the general assumption that ADF will probably get it right – Consider the greater cost of do-it-yourself (DIY)  Think AM Pools! – Good rule of thumb: One AM instance serves 10 - 15 users comfortably – Size for peak load based on this. 19 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Read. Understand. Tune.  http://docs.oracle.com/middleware/1212/adf/ adf-monitortune.htm 20 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • ADF Task Flow 21 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Bounded Task Flow Flows, Sub-Flows, Regions Bounded Task Flow Input Parameter Input Parameter Input Parameter Return Value Return Value 22 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Managed Beans
  • ADF Task Flow Architecture Best Practices 23 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Task Flow Oriented Architecture (TOA)  Think task flow from design time on – Inventory existing task flows – Identify patterns and standardize on them  Ensure objectives and requirements reflect task flow benefits – Reuse, loose-coupling  Think "unit-of-work" and factor task flow functionality into subflows – Share Data Control frame with sub-flows – Hide sub-flows from showing in ADF library 24 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Use Task Flow as a "Common Language"  Use task flow diagrammer as "common language" – Use task flow templates as blue prints – Use verbs and meaningful names in control flow case names  editOrder, createOrder, manageEmployee  Use the display and description properties of the contained activities to explain the non-obvious 25 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Task Flow Design Task Flow Sizing Considerations  Build Composite Task Flows – Larger task flows built out of several smaller task flows – Only top level task flow exposed for reuse – Encapsulates task flow dependencies  Good for distributing work among developers  Dependency management "by agreement" in smaller teams  Smaller memory foot print through load-on-demand and task flow private memory scopes 26 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • ADF Task Flow Implementation Best Practices 27 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Handling Input / Return Parameter Values  Save task flow input / return parameter values in managed beans in pageFlowScope – Easy to document – Type safe API – EL accessible – Easy to discover and manipulate input parameter values – NPE protection 28 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Managed Beans  Java classes configured in faces-config.xml, adfc-config.xml or <task-flow-name>.xml  Managed by JSF or ADF Controller – Java EE scopes  request, session, application – Additional ADF scopes  backingBean, view, pageFlow  Hold code for UI related logic and data 29 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Bounded Task Flow & Managed Beans Best Practice  Always use the smallest possible scope for managed beans – Helps Framework to "clean up" memory footprints – Think "state"  Does the managed bean need to keep state?  If so, how long?  Don't reference managed beans in session or application scope – Violates task flow isolation and reuse 30 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Data Control Scope  Use shared data control scope as often as possible – Less database connections – Simplifies task flow inter-communication – Automatic parent view collection to child task flow detail collection synchronization 31 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Task Flow Exception Handler  Define an exception handler activity in every bounded task flow  Leverage Task Flow Templates – Use as Blueprint or Reference – Define exception handlers for all bounded task flows 32 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • What Could Happen Task Flow Exception Propagation Memory Stack ! Task Flow 1 View1 EH Task Flow 2 Call Task Flow 2 View2 Current Task Flow ! Task Flow 4 EH Task Flow 3 Call Task Flow 3 Task Flow 3 View3 Task Flow 2 Task Flow 4 Call Current Task Flow Task Flow 4 View4 Method Call BANG! 33 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Task Flow 1
  • What Could Happen Task Flow Exception Propagation Memory Stack ! Task Flow 1 View1 EH Task Flow 2 Call Task Flow 2 View2 ! EH Task Flow 3 Call Propagate Exception Task Flow 3 View3 Task Flow 4 Call Task Flow 2 Current Task Flow Task Flow 4 View4 Method Call BANG! 34 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Current Task Flow Propagate Exception Task Flow 1
  • What Could Happen Task Flow Exception Propagation Memory Stack ! Task Flow 1 View1 EH Task Flow 2 Call Task Flow 2 View2 ! EH Current Task Flow Task Flow 2 Task Flow 1 35 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Visual Example Task Flow Exception Propagation ! BANG! 36 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Best Practices at a Glance Wildcard Navigation  Avoid cluttering diagrams for common navigation rules  Use wild card navigation for common functionality – Cancel – Commit 37 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • ADF Binding 38 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Understanding ADF Bindings How Oracle ADF binds into JSF Business Service Web Service ADF Data Binding Data Control POJO Data Binding JSF Page JUCtrl Generic Binding Expression Language ADF BC EJB ADF Faces Component Tag (<af:name../>) FacesCtrl Binding Server Side JSF Component JMX TopLink BAM 39 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Component Component Model UI Renderer
  • Programming Against the Binding Layer  Expression Language – Current binding layer can be accessed from #{bindings} or ${bindings}  Use from JSF components – Populate UI component value #{bindings.firstName.inputValue}  Use from PageDef file – E.g. access field binding value - ${bindings.firstName.inputValue}  Java – ADF binding layer is represented by Java objects at runtime – BindingContext.getCurrent()is the generic entry point 40 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Use Public APIs Only  ADF classes have an API package and an IMPL package – Define logical framework abstractions – Simplifies implementation of future product changes  APIs in IMPL package are internal-only – Not to be used outside of framework – Internal packages have "internal" in the naming (It’s a clue!)  If you are not sure … – Use EL in Java: #{bindings.allDepartments.treeModel.makeCurrent} 41 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Understanding ADF Programming Example: Accessing the Binding Layer import oracle.adf.model.BindingContext; import oracle.binding.BindingContainer; … BindingContext bctx = BindingContext.getCurrent(); BindingContainer bindings = null; bindings = bctx.getCurrentBindingsEntry(); 42 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Understanding ADF Programming Example: Accessing Attribute Binding AttributeBinding attributeBinding = null; attributeBinding = (attributeBinding)bindings.get("AttributeName"); /* set / get value */ attributeBinding.setInputValue(value); attributeBinding.getInputValue(); 43 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Understanding ADF Programming Example: Method and Action Bindings //get method or action binding OperationBinding methodBinding = (OperationBinding)bindings.get("methodOrActionName"); //optional: if method expects arguments Map paramsMap = methodBinding.getParamsMap(); paramsMap.put("argumentName1",value); Object result = methodBinding.execute(); //check for errors, e.g. exceptions List errors = method.getErrors(); If(!errors.isEmpty()){ …} 44 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Accessing Business Service Methods Best Practice  Encapsulate all model manipulation code in custom AM and/or VO methods & invoke them declaratively – Makes your app easier to regression test  Only code that belongs in a JSF managed bean is… – Complex, dynamic UI component manipulation – Complex conditional navigation  Even if you require backing bean code, invoke custom AM or VO methods using action binding – Guarantees uniform error handling 45 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Always Work Through the Binding Layer Best Practice – Accessing Business Service Methods View Layer Business Layer Business Service Application Module Managed Bean Data Model PageDef attribute binding Text method binding AM Impl public void invokePlSQL() Button AM Client Interface public void invokePlSQL() 46 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • ADF Model Error Handler  The ADF model error handler deals with – All ADF binding errors – Business service errors that occur when accessing a service trough the ADF binding layer  Formats and displays error message  Default error handler skips the top-level JboException because it only is a bundled exception wrapper for other business exceptions 47 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Build A Custom ADF Model Error Handler Best Practice  Extend oracle.adf.model.binding.DCErrorHandlerImpl and configure your custom error error handler in DataBindings.cpx  Override the following methods as needed – reportException  Override this method to analyze exceptions for errors you want to handle – getDisplayMessage  Override to change or suppress (null value) the displayed message – getDetailedDisplayMessage  Override this method to provide HTML markup formatted detail information – skipException(Exception ex)  Called by the framework to check if an exception should be ignored 48 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Configuring A Custom Error Handler 49 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • ADF Faces 50 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • ADF Faces Rich Client Components Based on Java Server Faces Standard  Ajax & HTML5 enabled JSF components  Pluggable look and feel  Accessibility & internationalization  Touch gesture support  Built-in advanced functionality: – Partial Page Refresh (PPR), Partial Submit – Drag and drop framework – Dialog and pop-up framework 51 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Backing Bean  "Special use" of a managed bean – Contain UI Component references  <af:inputText label="…" binding="#{BackingBeanName.lastNameField}"/> – Must be defined in request scope  JSF components are not serializable (!)  Best Practices – Avoid backing beans and perform dynamic component lookup using  FacesContext.getCurrentInstance().getViewRoot().findComponent(…)  Relative search: component.findComponent()  org.apache.myfaces.trinidad.util.ComponentUtils.findRelativeComponent(…, …) 52 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • When Using Backing Beans …  Use separate beans for separate views – Avoids "pinning" of UI components and their state – If views are exactly identical, consider reuse 53 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Avoid Expression Language Gotcha Manage Bean Scope – Prefix or don't Prefix?  EL accessing managed beans in Java EE scopes – Request, session, application – No scope prefix – #{beanName}  EL accessing managed beans in ADF scopes – backingBean, view, pageFlow – Require scope prefix – #{scope.beanName}, #{backingBeanScope.beanName} 54 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Put use of HTML on a "By Exception" List Avoid Mixing HTML and JSF components  HTML and JavaServer Faces are different technologies – Markup oriented vs. component oriented – Compile – Render, vs. multi stop request lifecycle  Facelets in JSF 2.x support mixing of HTML and JavaServer Faces components – Prior to Facelets and JSF 2.x, mixing HTML and JSF is a no-go – Still with JSF 2.0 problems may occur because ADF Faces components come with their own sizing behavior (geometry management)  Recommendation: Build pages and views with ADF Faces components 55 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Avoid ui:include and jsp:include Tags  ADF PageDef file is not aware of ui:include or jsp:include references in a page or view – Included fragments fail at runtime if they use ADF bound components – You can copy ADF bindings used by the included content into the view's PageDef file.  Prevents reuse of the fragments  Recommendation – Use ui:include and jps:include for layouts only (if at all) – Use ADF regions to add ADF bound content to a page at runtime 56 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Use inlineStyle and contentStyle By Exception Learn to Love Skinning  inlineStyle property allows developers to add CSS to a component rendering – CSS is applied to top-level DOM component – CSS is directly added to the page output – Best Practice: Use ADF Faces skinning and reduce the use of CSS to the absolute minimum (e.g. conditional color coding)  contentStyle property allows developers to add CSS to the value content area of an ADF Faces component – Styles component content area better than inlineStyle but has same issue as mentioned above 57 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • JavaScript 58 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • ADF Faces Client JavaScript Architecture DOM Form Client Side Server Side Servlet Label1 Label2 Label3 JSF Lifecycle OK Component Tree UI Components UI Components Form Document Peer Objects 59 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Form View Root Renderer
  • ADF Faces Client JavaScript Architecture Features  JavaScript component API  af:clientListener – Listens to DOM and ADF Faces component events  af:serverListener – XMLHttp JavaScript call to server – Queued as custom event on client – Answered by managed bean  ExtendedRenderKitService – Trinidad class to invoke JavaScript from Java 60 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Using JavaScript in ADF Faces Best Practice  Use JavaScript by Exception  Don't overuse JavaScript and first try and find a solution in ADF Faces  Put JavaScript code in external *.js files – Include using af:resource  Code against ADF Faces component model, not the browser DOM – Component oriented vs. markup oriented – "document.getElementById" is a serious programming mistake  Don't use JS classes in internal packages – See JavaScript docs 61 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Break Out Of Isolation. 62 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Join A Community  OTN forum – Best Practice  Articulate your question well – Take the same time for asking a question that you want forum members to spend on answering it – Keep questions short but comprehensive – Include your JDeveloper version  Use Google prior to asking to save time  Contribute  EMG – Architecture, integration, concepts and infrastructure topics – https://groups.google.com/forum/#!forum/adf-methodology 63 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Schau Dich Schlau Make yourself a smart cookie by watching ADF Architecture TV http://bit.ly/adftvsub 64 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Best Practices Summary Dress For Success Always work through the binding layer 65 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Don't fight the framework Think Task Flow
  • Best Practices Summary Dress For Even More Success Join a Community & Participate 66 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Use Case Matters Schau Dich Schlau!
  • Join the Oracle ADF Community http://oracle.com/ADF @jdeveloper /jdeveloper 67 JDeveloper ADF Insider ADF Architecture Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Learn More at Oracle OpenWorld Related sessions and labs Title Time Location Oracle ADF and Oracle ADF Mobile: Lessons Learned in Real-World Implementations Wed 11:45 Marriot – Golden Gate C3 Hands-on Lab: Developing Mobile Applications with Oracle ADF Mobile Wed 10:15 Marriot – Salon 12 One Size Doesn’t Fit All: Oracle ADF Architecture Fundamentals Thu 11:00 Marriot – Golden Gate A Oracle ADF booth at the Oracle Demo Ground – Moscone South 68 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • Graphic Section Divider 69 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • 70 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.