Академический Документы
Профессиональный Документы
Культура Документы
Disclaimer
This presentation outlines our general product direction and should not be relied on in making a purchase decision. This presentation is not subject to your license agreement or any other agreement with SAP. SAP has no obligation to pursue any course of business outlined in this presentation or to develop or release any functionality mentioned in this presentation. This presentation and SAP's strategy and possible future developments are subject to change and may be changed by SAP at any time for any reason without notice. This document is provided without a warranty of any kind, either express or implied, including but not limited to, the implied warranties of merchantability, fitness for a particular purpose, or non-infringement. SAP assumes no responsibility for errors or omissions in this document, except if such damages were caused by SAP intentionally or grossly negligent.
In this lecture you learn the most effective best1-hour practices to optimize the performance of your Web Lecture Dynpro Java application regarding an enhanced UI responsiveness on client side and minimized memory consumption on server side. The given recommendations and best-practice rules focus on different aspects related to user interface design, component granularity, component and controller lifecycle management, controller contexts, on-demand resources, table paging or models like the Adaptive RFC model. This session is based on Web Dynpro Java in SAP NetWeaver CE 7.1 so that performance rules related to the newest Web Dynpro Java Ajax features like the different flavors of suggestion, asynchronous input validation or the new UI element event onChange are also considered.
Agenda
1. Overview of Web Dynpro Java Performance Aspects 2. Web Dynpro Java Performance Guidelines
2.1. 2.2. 2.3. 2.4. 2.5. 2.6 Focus: User Interface Focus: Programming Model Focus: Controller Contexts Focus: Componentization Focus: Models Focus: New Ajax Functions
Application:
Network Latency
YOUR CODE!
SAP 2008 / SAP TechEd 08 / COMP204 / Page 5
Server-Side Rendering
(for each user interaction)
Browser Rendering
(for each user interaction)
Application:
Development Process
Main Objective: Know to Tackle Web Dynpro Java Performance Gremlins as a Developer
Components User Interface Contexts
Models
Programming Model
Ajax Functions
Agenda
1. Overview of Web Dynpro Java Performance Aspects 2. Web Dynpro Java Performance Guidelines
2.1. 2.2. 2.3. 2.4. 2.5. 2.6 Focus: User Interface Focus: Programming Model Focus: Controller Contexts Focus: Componentization Focus: Models Focus: New Ajax Functions
Prefer the Row layout to the Grid or Matrix layout if you dont need horizontal alignment (one column layouts). Prefer the Matrix layout to the Grid layout.
No need to specify column count. Helps to achieve consistent layouts via predefined paddings (property cellDesign).
User Interface
SAP 2008 / SAP TechEd 08 / COMP204 / Page 10
Client Time
Exchange Transparent Root Container UI Element with other Container Types in CE 7.1
New in NetWeaver CE 7.1 Exchange default root view element (TransparentContainerUIElement) with other container UI element (like TabStrip, Table, Group) to minimize container nesting levels
CE 7.1 CE 7.1
Answer: Use the key combination CTRL+ALT+SHIFT+O visualize the nesting in the browser in Web Dynpro screens. Focus a UI element first.
User Interface
SAP 2008 / SAP TechEd 08 / COMP204 / Page 11
CE 7.1
Client Time
Load Large Trees on Demand Use New Table Selection Change Behavior
Use load-on-demand (onLoadChildren event) to populate large trees.
Use the table selection change behavior by setting the table-property compatibilityMode == nw04Plus in NW 04 and NW 7.0 explicitly to enhance table performance.
Avoids a second implicit lead-selection roundtrip when triggering a single action Implement a parameter mapping relation for the UI element event parameter nodeElement Note: New table selection change behavior is default in NetWeaver CE 7.1 See SDN WebLog 2343 Enhancing Web Dynpro Java Table Performance CE 7.1 CE 7.1
Apply table paging techniques to populate large tables with hundreds of records
See special section on Web Dynpro Table Paging .
User Interface
SAP 2008 / SAP TechEd 08 / COMP204 / Page 12
CE 7.1
Memory
Server Time
Client Time
Web Dynpro does not render UI elements whose visibility property is set to WDVisibility.NONE
Instead of making multiple single UI elements invisible better set the embedding UI element containers visibility to WDVisibility.NONE Renderer does not have to loop all container elements on server side
User Interface
SAP 2008 / SAP TechEd 08 / COMP204 / Page 13
Server Time
Client Time
Adobe Interactive Forms are always a performance penalty for the following reasons ...
Remote call from the SAP NetWeaver AS Java to the ADS server to build the PDF file Additional roundtrips between the Acrobat Reader and the SAP NetWeaver AS Java to exchange the PDF file and the input data SOAP call to remote ADS server to create binary PDF resources PDF stream read/write with every request (almost!) PDF transfer from browser to the server and vice versa Additional application specific BAPI calls might take additional time
Usage of Zero Client Installation (ZCI) is strongly recommended Always use the latest ZCI script from Adobe inside the form.
User Interface
SAP 2008 / SAP TechEd 08 / COMP204 / Page 14
Server Time
Client Time
Performance recommendations on Web Dynpro Java application side Do not bind the pdfSource property until and unless the application needs the latest binary PDF available on the server. Use pdfResource property instead of pdfSource to leverage resource based optimizations (only send XML instead of binary PDF data).. Have a pre-created PDF and then use the same throughout the application session using usePdf mode.
UsePdf mode is disconnected from ADS for simple data transfer cases. It only gets connected to the ADS when it is absolutely required.
User Interface
SAP 2008 / SAP TechEd 08 / COMP204 / Page 15
CE 7.1
Server Time
Client Time
Agenda
1. Overview of Web Dynpro Java Performance Aspects 2. Web Dynpro Java Performance Guidelines
2.1. 2.2. 2.3. 2.4. 2.5. 2.6 Focus: User Interface Focus: Programming Model Focus: Controller Contexts Focus: Componentization Focus: Models Focus: New Ajax Functions
Implement wdDoModify() Hook Judiciously Use Context for Fine Grain UI Manipulations
Implement fine grain UI manipulations on context but not on UI element level to maximize the rendering performance:
Do not call the setter-methods of UI element objects inside wdDoModifyView() directly: Not: wdDoModifyView(){ theField.setEnabled(true) } Bind the related properties to the context and call the corresponding setter methods outside wdDoModifyView(): But: wdDoInit(){ wdContext.currentFieldNode.setEnabled(true) }. Especially bind UI element properties like readOnly, visibility, enabled, TreeNodeType.expanded, TabStrip.selectedTab or TableColumn.sortState to properly typed context attributes. The UI adapts automatically. Otherwise Web Dynpros caching mechanisms cannot speed up the rendering of view layouts!
Programming Model
SAP 2008 / SAP TechEd 08 / COMP204 / Page 17
Server Time
s Client Time
Programming Model
SAP 2008 / SAP TechEd 08 / COMP204 / Page 18
Memory
Server Time
Use additional custom controllers to keep the component controller as efficient as possible
Custom controllers are created on-demand. Therefore, moving functionality into a custom controller will delay its initialization from the start of the component controllers lifecycle to the point in time when it is actually needed. This can reduce the time taken for a component to start. Custom controllers should be used when you have identified a specific reuse case or when a distinct unit of functionality can be identified and separated from the main component controller.
Programming Model
SAP 2008 / SAP TechEd 08 / COMP204 / Page 19
Memory
Server Time
Create static URLs for static MIME resources via WDURLGenerator service which generates static URLs for MIMEs
(= deployable object parts) being stored and deployed in separate Web Dynpro DCs Configuration to create static MIME resource URLs at runtime (being stored in context) Common client implementations (like browsers) use caching mechanisms handling the lifetime of requested MIME objects.
Do not redundantly store session independent MIME resources per session in Web Dynpro Binary Cache or controller contexts:
WDWebResource.getWebResource(file, type) WDResourceFactory.createCachedResource() Instead, create static URLs for static MIMEs (see above)
Programming Model
SAP 2008 / SAP TechEd 08 / COMP204 / Page 20
Memory
Server Time
Client Time
Agenda
1. Overview of Web Dynpro Java Performance Aspects 2. Web Dynpro Java Performance Guidelines
2.1. 2.2. 2.3. 2.4. 2.5. 2.6 Focus: User Interface Focus: Programming Model Focus: Controller Contexts Focus: Componentization Focus: Models Focus: New Ajax Functions
Minimize Generation of Typed Context APIs Avoid Context Mapping if not Needed
When declaring context nodes set property typedAccessRequired == false in case
a typed context access is not required within the controller coding. This is often the case when defining mapped view context elements. a context node contains many attributes but only a few attributes are accessed inside the controller coding. Access these attributes with the generic context APIs IWDNode and IWDNodeElement instead.
Controller Contexts
SAP 2008 / SAP TechEd 08 / COMP204 / Page 22
Memory
Dont Declare Context Model Nodes and Attributes NOT used for Data Binding Purposes
When model data retrieved via backend connections (Adaptive RFC, Web Service, EJB) has NOT to be transferred to the user interface via data binding:
There is no need to declare context model nodes and attributes bound to model classes and attributes for storing business data in the context. Just programmatically operate on model objects directly to access model data in your controller classes
By omitting the definition of a context-to-model binding relation in a controller context, the generated context interfaces are kept as slim as possible, and this reduces the permanent memory space* on server side.
Controller Contexts
SAP 2008 / SAP TechEd 08 / COMP204 / Page 23
Memory
Apply Alternative Techniques to Share Data Across Controller and Component Borders Consider other techniques than context mapping to share data NOT used for data binding across controller and component borders: server-side eventing (component interface) controller method Invocation navigation plugs (inbound and outbound plugs) Use private non-satic member variables instead of context attributes to store and access Java objects NOT used for data binding inside controller classes.
Controller Contexts
SAP 2008 / SAP TechEd 08 / COMP204 / Page 24
Memory
Define singleton nodes to minimize the memory footprint of a controller context at runtime:
Controller Contexts
SAP 2008 / SAP TechEd 08 / COMP204 / Page 25
Memory
Controller Contexts
SAP 2008 / SAP TechEd 08 / COMP204 / Page 26
Memory
Server Time
Retrieval of detail model objects associated with master model objects is too expensive for all node elements:
Bind a non-singleton [1..1] or [1..n] child node to the detail model class and declare a supply function for it. The supply function is only called for the rendered (validated) child nodes (visible table rows) referencing the detail model objects. Explicitly invalidate these inner child nodes when detail model object retrieval is required again. Binding a new list of node elements or model objects to a context will invalidate all child nodes. Controller Contexts
SAP 2008 / SAP TechEd 08 / COMP204 / Page 27
Memory
Server Time
supply function is called for every validated (rendered/visible) nonsingleton child node instance Controller Contexts
SAP 2008 / SAP TechEd 08 / COMP204 / Page 28
Memory
Server Time
IWDResource
createResource(IWDResourceContentProvider provider, String resourceName, WDWebResourceType type) Method creates an instance of IWDResource, which is bindable to FileDownload-UIElement. Resource is created on-demand by the resource content provider implementation.
Controller Contexts
SAP 2008 / SAP TechEd 08 / COMP204 / Page 29
Memory
Server Time
Agenda
1. Overview of Web Dynpro Java Performance Aspects 2. Web Dynpro Java Performance Guidelines
2.1. 2.2. 2.3. 2.4. 2.5. 2.6 Focus: User Interface Focus: Programming Model Focus: Controller Contexts Focus: Componentization Focus: Models Focus: New Ajax Functions
Optimize the application architecture with the best Web Dynpro component granularity
Rule of Thumb: implement 1 Business Task in 1 Web Dynpro component Dont make Web Dynpro components too large distributing work between several developers is harder reusability is very poor But: Dont make Web Dynpro components too small the application might not perform well the resulting sea of components might reduce maintainability reuse level too small higher system overheads
Componentization
SAP 2008 / SAP TechEd 08 / COMP204 / Page 31
TCD
Componentization
SAP 2008 / SAP TechEd 08 / COMP204 / Page 32
TCD
Componentization
SAP 2008 / SAP TechEd 08 / COMP204 / Page 33
TCD
CE 7.1
Split your Web Dynpro Application into separate Web Dynpro DCs
Apply Web Dynpro Component Separation Principles
Create a single root component which embeds and layouts separate UI components. Separate the UI in visual Web Dynpro components Centralize model access in a faceless model component and use this singleton model component in other components by applying the component usage referencing mode.
Web Dynpro DC
Web Dynpro DC
Componentization
SAP 2008 / SAP TechEd 08 / COMP204 / Page 34
TCD
Apply Component Interface Definitions For Loose Component Coupling (Strategy Pattern)
Separate the component interface definition from the component interface implementation (strategy design pattern):
FIRST: Define Web Dynpro components on an abstract level: component interface: context structure, public methods, events component interface view: inbound plugs, outbound plugs used models THEN: Implement the given component interface definition in one or more concrete Web Dynpro component(s)
Advantages:
Loose Coupling: Component user can program against separately defined component interfaces (implementation is hidden) without declaring hard component usage(s) to one (or many) component implementations. Component implementation can be provided (or selected) later on at run time. Larger Web Dynpro applications can be effectively developed by many developers
Componentization
SAP 2008 / SAP TechEd 08 / COMP204 / Page 35
TCD
Componentization
SAP 2008 / SAP TechEd 08 / COMP204 / Page 36
Memory
Server Time
To implement other Web Dynpro Java dependant code that requires a Web Dynpro component (like shared contex nodes etc.), then a component makes sense and then you could incorporate the new method there as well.
Componentization
SAP 2008 / SAP TechEd 08 / COMP204 / Page 37
Memory
Server Time
Agenda
1. Overview of Web Dynpro Java Performance Aspects 2. Web Dynpro Java Performance Guidelines
2.1. 2.2. 2.3. 2.4. 2.5. 2.6 Focus: User Interface Focus: Programming Model Focus: Controller Contexts Focus: Componentization Focus: Models Focus: New Ajax Functions
Apply Adaptive RFC Models for accessing RFC modules in SAP systems
Do not circumvent the Adaptive RFC layer by implementing your own, JCo-based, access to RFC modules which are exposed in a SAP system
Dont transfer table values as export or import parameters Dont embed tables within RFC import, export or table parameters Dont implement data intensive operations on the UI layer, for example, sorting and filtering of context model node elements
Instead, data intensive operations should already take place in the backend implementation (RFCs) itself. In this case the required unmarshalling is minimized
Models
SAP 2008 / SAP TechEd 08 / COMP204 / Page 40
TCD
Memory
Server Time
Put as many RFCs in a single Adaptive RFC model as possible Put RFCs into separate models only in case of
different RFCs in different backend systems have to be jointly accessed in one Web Dynpro application. This requires different connections. different lifecycles of the RFCs. These RFCs can then be kept and updated independent of each other. componentization across different DCs. In this case RFCs should also be separated.
Place Web Dynpro Models into separate model DCs. Therefore, model DCs will only be rebuilt when they change. TCD TCD
This greatly speeds up the development process.
Only re-import an Adaptive RFC Model when a table, which was defined as an import or export parameter before, is defined as a table parameter afterwards TCD TCD
Models
SAP 2008 / SAP TechEd 08 / COMP204 / Page 41
TCD
Memory
Server Time
Agenda
1. Overview of Web Dynpro Java Performance Aspects 2. Web Dynpro Java Performance Guidelines
2.1. 2.2. 2.3. 2.4. 2.5. 2.6 Focus: User Interface Focus: Programming Model Focus: Controller Contexts Focus: Componentization Focus: Models Focus: New Ajax Functions
There is also an increased number of server roundtrips when the InputField suggestion is based on on-demand valuesets or static valuesets defined in dictionary simple types with MORE than 200 values:
A matching chunk valueset with 200 values is retrieved in a first roundtrip. In additional roundtrips new valuesets matching the user input are retrieved from the server successively. see WDSimpleValueSupplier
CE 7.1
CE 7.1
Server Time
Client Time
Therefore use the new onChange UI element event judiciously when server-side logic is inevitably required. Note: With the new onChange event it is first possible that two action events are handled in the same server roundtrip.
Example: The user has changed an input field value and then directly presses a form button afterwards (without intermediately editing another field). The client then triggers two action events (onChange and onAction) in the same roundtrip to be processed on server side. The Web Dynpro Runtime first handles the action to which the onChange event is bound.
CE 7.1
Server Time
Client Time
Agenda
1. Overview of Web Dynpro Java Performance Aspects 2. Web Dynpro Java Performance Guidelines
2.1. 2.2. 2.3. 2.4. 2.5. 2.6 Focus: User Interface Focus: Programming Model Focus: Controller Contexts Focus: Componentization Focus: Models Focus: New Ajax Functions
3. Special: Web Dynpro Java Table Paging 4. Performance Tools Overview 5. Summary
Apply Table Paging Techniques to Reduce Memory and to Enhance Client Performance
Optimize performance with server-side table paging techniques to display a large number of table rows
highly reduced memory consumption by retrieving displayed table records on demand and caching them on Web Dynpro server side rapid initial table display based on minimized number of records initially retrieved from the backend exact table page navigation based on reading scrolltips in vertical table scrollbar
Technical Solution
Implement ICMIObservableList-API extending generic abstract base implementation class CMIAbstractObservableList. No supply function needed to populate the tables data node based on binding an ICMIObservableList object instance to it. Read fixed page size (= number of records per backend call) in one backend call. Only read displayed table records from backend on-demand after rendering phase.
CE 7.1 CE 7.1
For further details see SDN Wiki Page on How to Implement Table Paging Server Time Client Time
Table Paging
SAP 2008 / SAP TechEd 08 / COMP204 / Page 47
For further details see SDN Wiki Pages on Web Dynpro Java Table Paging and How to Implement Table Paging
Table Paging
SAP 2008 / SAP TechEd 08 / COMP204 / Page 48
Server Time
Client Time
DEMO
See Table Paging Demo Application Running on SAP NetWeaver CE 7.1
SAP 2008 / SAP TechEd 08 / COMP204 / Page 49
Agenda
1. Overview of Web Dynpro Java Performance Aspects 2. Web Dynpro Java Performance Guidelines
2.1. 2.2. 2.3. 2.4. 2.5. 2.6 Focus: User Interface Focus: Programming Model Focus: Controller Contexts Focus: Componentization Focus: Models Focus: New Ajax Functions
3. 4. 5. 6.
Special: Web Dynpro Table Paging Performance Tools Overview Outlook Summary
Show Stacked Performance Infos for ALL Roundtrips in Running Client Session
Note: while running in the portal most URLs are calculated during the navigation. You can grep the URLs, run the app in separate browser window and then add the URL parameter there.
Parameter Parsing JSBefore Html JSAfter Description, times in [ms] Time for parsing HTML Time for processing JavaScript code before HTML rendering Time for rendering HTML Time for processing JavaScript code after HTML rendering Time to process and dispatch an incoming request to the Web Dynpro Runtime Time needed by the Web Dynpro Runtime to process the complete phase model Time for accessing the backend (executing ARFC, ESF, AWS model classes) Not measured (0) when other models are used (JavaBean, EJB Model) Estimated response size in kilobytes.
Browser
Agenda
1. Overview of Web Dynpro Java Performance Aspects 2. Web Dynpro Java Performance Guidelines
2.1. 2.2. 2.3. 2.4. 2.5. 2.6 Focus: User Interface Focus: Programming Model Focus: Controller Contexts Focus: Componentization Focus: Models Focus: New Ajax Functions
Main Objective: Know to Tackle Web Dynpro Java Performance Gremlins as a Developer
Components User Interface Contexts
Models
Programming Model
Ajax Functions
Now You know How to tackle the Web Dynpro Java Performance Gremlins
Components User Interface Contexts
Models
Know How Your Declarations and Code Affect Memory, Client and Server Time Apply Performance Tools
Ajax Functions
To learn more or to get your own SDN Subscription, visit us at the Community Clubhouse or at www.sdn.sap.com/irj/sdn/subscriptions
SAP 2008 / SAP TechEd 08 / COMP204 / Page 57
Further Information
SAP Public Web:
SAP Developer Network (SDN): www.sdn.sap.com SAP NetWeaver UI https://www.sdn.sap.com/irj/sdn/nw-ui Web Dynpro Java https://www.sdn.sap.com/irj/sdn/nw-wdjava
Thank you!
Thank You !
SAP 2008 / SAP TechEd 08 / COMP204 / Page 60