JA310 Col54
JA310 Col54
Internal
Only
JA310
Java Web Dynpro
Partner
Use
THE BEST-RUN BUSINESSES RUN SAP
SAP
SAP
SAP AG©2004
SAP AG 2004
Partner
Use
SAP NetWeaver™
2005/Q4
Material number 50070818
Internal
Only
Copyright
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Some software products marketed by SAP AG and its distributors contain proprietary software components of
Partner
other software vendors.
Use
Microsoft, Windows, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation.
IBM, DB2, DB2 Universal Database, OS/2, Parallel Sysplex, MVS/ESA, AIX, S/390, AS/400, OS/390, OS/400,
iSeries, pSeries, xSeries, zSeries, z/OS, AFP, Intelligent Miner, WebSphere, Netfinity, Tivoli, and Informix are
trademarks or registered trademarks of IBM Corporation in the United States and/or other countries.
Internal
Only
HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C®, World Wide Web
Consortium, Massachusetts Institute of Technology.
Java is a registered trademark of Sun Microsystems, Inc.
JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and
implemented by Netscape.
MaxDB is a trademark of MySQL AB, Sweden.
SAP, R/3, mySAP, mySAP.com, xApps, xApp, and other SAP products and services mentioned herein as well as
their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other
countries all over the world. All other product and service names mentioned are the trademarks of their respective
companies. Data contained in this document serves informational purposes only. National product specifications
may vary.
These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated
companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and
SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP
Group products and services are those that are set forth in the express warranty statements accompanying such
products and services, if any. Nothing herein should be construed as constituting an additional warranty.
Course Prerequisites
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Target Group
z Participant
Developers of Java Web Dynpro Applications
z Duration: 3 days
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
These training documents are not meant to be used without corresponding classroom
instruction. They are only complete when used in tandem with the comments of an SAP trainer.
Internal
Space is provided for you in the course documents to note this additional information.
Only
Course Goals
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Content (1)
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Content (2)
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
SAP Java Development Environment
Contents:
z SAP NetWeaver Developer Studio
z Technical System Landscape, Administration Tools
z SAP Component Model
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Plug-In
Plug-In
Java Workbench
development Help
tools (JDT) JFace
Internal
Only
SWT Plug-In
Plug-In
Plug-In
Plug-In
development
development Workspace VCM
environment
environment
Partner
(PDE)
(PDE) Plug-In
Plug-In
Platform runtime
environment
Use
Eclipse SDK
SAP
SAP
SAP AG 2004
Partner
Use
along with other reputable companies such as Borland, IBM, Merant, Rational Software, RedHat, SuSE,
and TogetherSoft etc.
Architecture
Only
During development of the Eclipse IDE, great importance was initially placed on the ability to enhance
this development. Core applications for the platform runtime environment can be enhanced using plug-
ins.
y Workbench
- Defines the structure of the interface development using Eclipse. JFace is built for collaboration
with the Standard Widget Toolkit (SWT).
- Performs standard tasks in interface creation, such as access to pictures and fonts, standard dialogs,
etc.. API and implementation are independent of the underlying window system.
y Standard Widget Toolkit (SWT)
- Pre-defined assembly for interface elements and graphical display. Implementations are available
for Windows and Motif.
y Workspace
- Allows Java applications to be incorporated in projects. Offers a history mechanism to protect
against loss of data by saving the contents of resources that have been changed and deleted.
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Plug-Ins
Plug-Ins declare any number of enhancement areas to which other plug-ins can be attached. When the
Eclipse Platform is started, the system determines the number of available plug-ins and their
connections.
Internal
Plug-ins are activated using a “lazy access” concept; that is, a plug-in is not activated until it is required.
Only
The Eclipse Platform is structured using various plug-ins.
Internal
Only
Partner
Use
Task Outline Overview of the
View View Java Hierarchy
SAP
SAP
SAP AG 2004
Partner
Use
Only
Java Editor
The Java Editor contains every possible option for making development easier using Code Completion,
Templates, QuickFix, Syntax Check, Immediate Translation, Local History, Code Generation and much
more.
Eclipse contains various options for Refactoring. This is the name given to the process of making
widespread changes throughout a projects – such globally renaming a class method.
Debugger
The integrated debugger contains a number of useful functions for J2EE developers, such as Remote
Debugging, Breakpoints with Conditions, Hit Counts etc.
Internal
Only
Infrastructure
Web Services
UML Modeller
J2SE
Web Dynpro
Persistence
Party Tools
& other 3rd
Dictionary
Partner
Tools
Tools
Tools
Tools
Tools
Tools
Tools
J2EE
Java
Use
SAP Integration Framework
SAP
SAP
SAP AG 2004
Partner
Use
SAP Web Dynpro tools can be used to develop flexible Web interfaces.
y E-business logic
The SAP NetWeaver Developer Studio supports you in the development and deployment of EJB’s
Only
and in the definition and publication of Web Services.
y Java persistence
State-of- the-art technologies, such as Container Managed Persistence (CMP), embedded SQL in Java
(SQLJ) und Java data objects (JDO) are supported by the corresponding tools.
You can also define platform-independent data types and database objects in the Java Dictionary.
The SAP NetWeaver Developer Studio combines a number of tools in one package. It supports local
development recognized by Java, but also contains a number of Plug-Ins that can be used for team-
oriented development, testing and deployment of business applications using version management.
The SAP NetWeaver Developer Studio also contains additional tools, such as design-time support for
HTML, XML and XSLT (validation, code completion).
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Only
This led to the request for a development platform in the format currently available with the ABAP
Workbench but with the additional benefit of a local development environment.
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Only
- JDK 1.4.2 or higher
- Internet Explorer 6.0 or Netscape Navigator 7.0 or higher
y Default local Developer Studio path is C:\Program Files\SAP\JDT\eclipse
y Default local workspace path is C:\Documents and Settings\All Users\Documents\SAP\WorkSpace
- Unless multiple users are sharing the same development machine, then a shorter name should be
chosen such as C:\Workspace. This because the Windows™ Operating System has a built-in path
name length limit of 255 characters. If excessively long development entity names are chosen, then
it is possible that Eclipse could generate file names that exceed this limit.
- This limit can be checked for at design time, but not at deploy time.
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Preferences
The Preferences dialog can be found from the main workbench Window menu under Window →
Preferences.
Internal
If a plug-in requires any configuration, then this can normally be performed through the relevant
preference page.
Only
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Only
Support for J2EE projects, Web Components (JSP, Servlet), XML
y Dictionary Perspective
Definition of database tables and simple types
y Web Service Perspective
Creation of Web Service client proxy definition
y Design Time Repository (DTR) Perspective
DTR client allows easy file handling on the file server
y Development Components Perspective
Display and edit a Development Component
y Development Configurations Perspective
Provides task-specific DTR access
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Views
Within Eclipse, views are navigation tools that support editors and provide alternative presentations of
your project file hierarchy.
y Views have their own menus. To open the menu for a view, click the icon at the left end of the view's
Internal
title bar. Some views also have their own toolbars. The actions represented by buttons on view
toolbars only affect the items within that view.
y A view might appear by itself, or stacked with other views in a tabbed window. You can change the
Only
layout of a perspective by opening and closing views and by docking them in different positions in the
Workbench window.
Close single
file
Internal
Only
Double-
Partner
clicking the
toolbar
adapts
Use
the size of
any view to
Close perspective screen size,
Close view and back !
via context menu
SAP
SAP
SAP AG 2004
Partner
Use
Perspectives
Each Workbench window contains one or more perspectives and defines the initial set and layout of
views in a Workbench window. Within the window, each perspective shares the same set of editors and
controls what appears in certain menus and toolbars.
Internal
y Each perspective provides a set of capabilities aimed at accomplishing a specific type of task or works
with specific types of resources. For example, the Java perspective combines views that you would
commonly use while editing Java source files, while the Debug perspective contains the views that
Only
you would use while debugging Java programs.
y Perspectives can be customized and saved. You can then set your Workbench preferences to open
your perspectives in the same window or in a new window.
y As you work in the Workbench, you will probably switch perspectives frequently.
Internal
Only
Partner
Use
Message Editor Source code editor
SAP
SAP
SAP AG 2004
Partner
Use
Editors
Depending on the type of file you are editing, the appropriate editor is displayed in the editor area. For
example, if you are editing a .TXT file, a text editor is displayed in the editor area. The name of the file
appears in the tab of the editor. If an asterisk (*) appears at the left side of the tab this indicates that the
Internal
editor has unsaved changes. If you attempt to close the editor or exit the Workbench with unsaved
changes you will be prompted to save your editor's changes.
Dummy Web Dynpro Project file
Only
When editing a Web Dynpro Project, you will see a dummy file appear in the editor window. This
represents the fact that some file belonging to a Web Dynpro Project has been edited. This dummy file
will stop you from shutting down Eclipse without saving the changes to your project.
XML editor
Select an XML file in the Navigator view, and select Open With → XML Editor.
Result: The XML Editor is displayed in the right perspective pane.
Switch to the XML source via the tab Source.
z Result:
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Project management
You can open multiple projects at the same time. There are different ways to open projects:
y Create a non-Development Component (DC) project
Select File → New → Project → <project type>
Internal
y Create a DC project
Select File → New → Project → Development Component → Development Component Project →
<project type>
Only
y Import a project
Select File → Import → Multiple Existing Projects into Workspace
Browse to the workspace path, and select the corresponding projects you want to import.
y J2SE project migration support (switch 6.20 to 6.30 IDE)
Select File → Import → jpx Project. Some manual adaptation will be necessary.
y Project check-out/check-in from DTR
Performance warning!
When Eclipse starts up, it buffers all open projects into memory! Therefore, Projects or Development
Components that you are not working on should not be left open.
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Application Server
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Use
z Single z Multiple NetWeaver Developer Studios
Developer Workplace connecting to a common
SAP Web AS J2EE system
SAP
SAP
SAP AG 2004
Partner
Use
The SAP NetWeaver Developer Workplace consists of an SAP Web Application Server J2EE system
and the SAP NetWeaver Developer Studio.
Each part of the SAP NetWeaver Developer Workplace can be installed separately. This allows the
following installation options:
Internal
1. A combined installation of the SAP NetWeaver Developer Studio and the SAP Web Application
Server J2EE system. This option provides a complete development and test environment for each
developer.
Only
2. A standalone installation of the SAP NetWeaver Developer Studio for each developer and a
standalone central test SAP Web Application Server J2EE system. This option provides a single
development environment and a common test environment for multiple developers. This can be used
for instance for a larger developer group working on separate development projects.
Save / Deploy
load
File
System
SAP Management Console
Internal
Only
Telnet
Partner
Web Container
Use
Config Tool
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
The SAPMMC presents information on two panes of a window. The pane on the left is the scope pane.
It displays available information in a tree structure that can be expanded and compressed. The pane on
the right is the result pane. It shows detailed information about any item selected in the scope pane.
Only
On your installation host double-click the SAP Management Console icon on your desktop. The
SAPMMC screen appears.
In the left pane you can open the tree SAP Systems → <SAPSID> tree.
The <SAPSID> node is called the system node.
To start and stop the entire system, right-click on the system node and chose Start or Stop.
With the same procedure you can start and stop the instance nodes.
Caution: If you start via the system node by choosing Start, the database is started also. The Stop
procedure, however, does not affect the database, therefore you need to stop the database via the blue
icon, if required (for a SAP DB installation, choose Offline to stop and Online to start the database).
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Visual Administrator
SAP J2EE Engine Visual Administrator is a graphical tool for administering a J2EE cluster as a whole,
all cluster elements, and all modules running on them. It provides remote monitoring and management of
managers, services, libraries, and interfaces working on each element in a single GUI. The Visual
Internal
Only
y Log viewing
Starting the Visual Administrator
The Visual Administrator is not part of the NetWeaver Development Studio.
The start script for the Visual Administrator can be found under the directory
/usr/sap/<SID>/JC<InstanceNumber>/admin.
Use go.bat on Windows systems and go.sh on Unix systems.
Logging on to the SAP J2EE Engine consists of two steps:
y In the first step you have to configure the list of connection properties for connecting the Visual
Administrator tool to the SAP J2EE Engine, or select a previously configured entry that you want to
connect to.
y In the second step, you have to specify the properties of the user and the connection.
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Telnet
An entire J2EE engine cluster can be remotely administered using a standard Telnet client. Within the
J2EE engine, there is a Telnet Provider Service that must be started before this service can be used.
The default port for the J2EE Engine telnet service is 50008.
Internal
By default, the Telnet shell is opened on the dispatcher. Once you are connected you can access and use
all shell commands available on the different J2EE Engine cluster elements. Use the LSC command to
display all server components with their ID, component name, host, port, and type. The first component
Only
displayed is the current one.
To connect from one component to another, use the JUMP command and specify the ID of the target
element. For example, executing jump 4001 enables the remote administration of a cluster element with
ID 4001. Entering “jump 0” is a shortcut to the first server component in the list.
You can obtain an overview of the available commands with the command MAN.
MAN <command> displays a short explanation of a command.
The commands are grouped into a number of groups that can be activated and deactivated. You can
obtain an overview of the groups with the command ADD. To activate a group of commands, enter the
command ADD <group>.
For instance, you can manually deploy an Enterprise Archive (EAR) file using this command line
interface. But before you can do so, you must activate the deployment command set by first entering
“add deploy”. After this, the “deploy” command is available to you.
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Config Tool
The SAP J2EE Engine GUI Config Tool enables configuration of J2EE Engine cluster elements
concerning properties, adding new elements, and exporting the system configuration to the Database.
After installing the J2EE Engine a configtool directory is created, containing a configtool script file.
Internal
Only
y Server configuration
y Cluster element properties
y Modifying manager or service of properties
y Creating new elements
y Applying the changes and exporting to an XML file
y Managing secure store data
The start scripts for the ConfigTool can be found in
usr/sap/<SID>/JC<InstanceNumber>/j2ee/configtool
Use the scripts configtool.bat or configtool.sh to start the configTool GUI.
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
y Division into individual components means working with large software projects is easier.
y The Design Time Repository versions the source codes in a central location.
y The Build Service creates components that can be run.
Only
y The Change Management Service supports you in the delivery of software.
z Products
Collection of various
software components Product version
Internal
Only
without overlaps
*
z Development Components (DCs) DC version
Development objects for build process 1
Partner
Use
z Development Objects
Are saved as versioned files in the DTR
SAP
SAP
SAP AG 2004
Partner
Use
code.
y Packages could not be broken down.
y Once classes have been declared as "public", they can be used everywhere. There is no option to
Only
control the fact that specific modules/components can use classes and others cannot.
Component Types
The Component Model from SAP distinguishes the following component types:
y Software Components (SC)
SCs are the smallest installable unit of a SAP Product. They have their own release cycles and
maintenance ranges. They are a superset of:
y Development Components (DC)
These contain individual development objects such as Java packages.
y Component definitions are recorded in files and versioned in the DTR (Design Time Repository).
Build unit DC C
z Nested DCs
DCs can be nested within
usage
each other (restricted access)
dependency
Internal
Only
z Usage dependencies DC X
Indicates that a DC part can be used ppY
by other DCs (during the build process
Use
or during the runtime) DC Y
SAP
SAP
SAP AG 2004
Partner
Use
Development Component
DCs are containers for all types of development object (such as classes, interfaces, table declarations
etc). These objects can be made visible externally using the "public part" of a DC.
Internal
Several pre-configured DC types (such as Web Dynpro, Data Dictionary, Web Services etc) are
available.
Only
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
1-1 Open a connection to the Telnet Administration Service on your Web AS test system.
1-2 Logon as user Administrator.
Use
1-3 Find out which commands are available
1-4 List all active cluster elements (Hint: Use command ‘man lsc’).
SAP
SAP
Partner
Use
2-3 Which data sources are configured in the JDBC Connector Service of your J2EE
Engine?
Only
3 Using the Config Tool
3-1 Open the ConfigTool.
3-2 Check on which port the Telnet service for the dispatcher of the J2EE Engine is
configured?
Internal
Only
1-1 Open a connection to the Telnet Administration Service on your Web AS system
Use
telnet <hostname> 50008
SAP
SAP
Partner
Use
Only
1-3 List available commands.
Type command
man
Internal
Only
man jump
jump
The command jump lists all available cluster
nodes where you can jump
Partner
Use
1-6 Optional: How many free database connections are available at your J2EE Engine?
SAP
SAP
man
add dbpool
man
Partner
Use
data source
get_ds
Only
get_free_conn SAPC11DB
Internal
Only
Use
SAP
SAP
2-3 Which data sources are configured in the JDBC Connector Service of your J2EE
Engine?
Partner
Use
Path:
Server ->Services-> JDBC Connector
Internal
-> DataSources
Only
Internal
Only
3-2 Check on which port the Telnet service of the dispatcher of the J2EE Engine is
Partner
configured.
Use
Check the configuration for Telnet service
SAP
SAP
Partner
Use
Internal
Only
Contents:
z Introduction to the Web Dynpro architecture
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Only
on the client, and where those elements will get their data from. All the code to create the user interface
is then generated automatically within a standard runtime framework. This relieves you from the
repetitive coding tasks involved in writing HTML and then making it interactive with JavaScript.
Internal
Only
z Achieve Independence
run on multiple platforms
Use
client-side dynamics
performance through caching
508 accessibility support
flicker-free screen, minimal refreshes Multi Channel Access
SAP
SAP
SAP AG 2004
Partner
Use
the UI, the better. Web Dynpro pursues this goal in two ways.
y Web Dynpro uses a declarative, language-neutral metamodel for defining a user interface. From this
abstract definition, The SAP NetWeaver Development Studio generates the required Java code. Hand-
Only
written code still has its place, but is confined to that required to manipulate the business data, not the
user interface.
y Web Dynpro provides technical features such as support for internationalization, flicker-free
interaction and a clean separation of the business logic and the user interface. This separation is
achieved through a modified implementation of the Model-View-Controller (MVC) design paradigm.
MVC was invented by Trygve Reenskaug in the late seventies and first implemented in the Smalltalk-
80 language.
Since the repetitive tasks of UI coding have been all but eliminated, the developer can focus their
attention on the flow of business data through the application.
Web Dynpro applications can run on a range of devices and on various types of network – an important
feature for collaboration scenarios.
Meta-data
Deployable App
Generated
Compiler
Web Code
Dynpro Generator
Tools Custom
Code
Internal
Only
Use
Data Flow
SAP
SAP
SAP AG 2004
Partner
Use
is then generated automatically and conforms to a standard architecture known as the Web Dynpro
Framework (WDF).
The WDF allows each controller within a component to have a set of standard hook methods. It is within
Only
these hook methods that any required custom coding can be placed.
In addition to the events provided by the WDF, you can also define your own events for a Web Dynpro
application.
All Web Dynpro applications are constructed from the same basic units. However, through the use of
custom in the standard hook methods, the standard framework can be extended to supply any required
business functionality.
Not all implementation decisions need to be made at design time. It is perfectly possible to implement a
Web Dynpro application in which the appearance of the user interface is decided at runtime. This allows
a highly flexible application to be written without requiring the need to directly write any HTML or
JavaScript.
Web Dynpro application metadata is platform independent. It is therefore possible to develop an
application on one platform and then deploy it on another.
Internal
Only
J2EE ABAP
Deployed Web Web Dynpro
Deployed Web
Dynpro App Web Dynpro Web Dynpro Web Dynpro
App
Dynpro App Runtime Runtime App
Partner
Conversion
SAP of existing
HTTP Dynpros
NetWeaver
Developer
Use
ABAP Workbench
Studio
Web Dynpro
Application
SAP
SAP Enterprise Portal
SAP
SAP AG 2004
Partner
Use
Only
y External XMI models (TogetherSoft / Rational Rose): A UML definition can be imported as an XMI
file with wizard support (Web Dynpro Model Tools).
Internal
Only
Floor plans:
Screen layout, interaction and
semantics for a generic
application
Partner
Use
less specialized knowledge
SAP
SAP
SAP AG 2004
Partner
Use
Pattern-based UI Design
A UI pattern is a generic solution for providing an interface to a user task. Technically, a UI pattern is a
generic, configurable Web Dynpro UI element group that has been built to deal with tasks common to a
number of applications.
Internal
Only
y More rapid and efficient software development
y Lower development costs
y Reuse
y Reduced maintenance requirements
y Improvements to patterns can be made once centrally
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Externally
Visible
Interface view
Controller
Interface
Internally
Visible
Interface
View
Controller
Implements
Usage declarations
Window Component
Internal
Only
Controller
Contains Usage
Components
declarations
Custom Controller
Model 1
Partner
View View
Layout Controller
Use
Model 2
W e b D y n p r o C o m p o n e n t Models
Visual Entities Programmatic Entities
SAP
SAP
SAP AG 2004
Partner
Use
The architecture of a Web Dynpro Component can be divided into four quadrants:
y The horizontal dotted line separates the entities that are visible from outside the component, from
those that are only visible from within the component.
y The vertical dotted line separates the visual entities from the non-visual, or programmatic entities.
Internal
The only parts of a Web Dynpro Component that are visible to the outside world, are the interface
controller and the interface view(s).
y All Web Dynpro components have an Interface Controller.
Only
y There is a one to one relationship between a Window and an Interface View.
y If the component has no views, then it will have no Windows, which in turn, means that it will not
implement an interface view. Such components have no visual interface and are known as “faceless”
components.
Within a Web Dynpro component, all controllers are independent programs; however, they all play a co-
operative role. No controller can function in isolation from its parent component.
Notice that Web Dynpro Models stand outside the Component. Models are reusable across multiple
components.
A Web Dynpro Component can declare the use of another Web Dynpro Component. A specific
component usage is then created and the parent component accesses the functionality of the child
component via its component interface controller.
Internal
Only
Use
This hierarchy is only visible through the Web
Dynpro Explorer perspective
SAP
SAP
SAP AG 2004
Partner
Use
The root node of a Web Dynpro Project or Development Component represents the deployable unit of
coding. This should contain one or more Web Dynpro applications.
The node Web Dynpro is the node under which all Web Dynpro applications, models and components
live.
Internal
Each Project or Development Component has two types of dictionary available to it:
y A Local Dictionary in which all scalar and structured data types are defined.
y A private dictionary per model object.
Only
The folder src is a reference (only display) showing
y Configuration
y Mimes
y Packages (metadata, not generated Java sources)
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
A Component represents a set of tasks that form a logical business unit. Components can be embedded
within other components and are not addressable via a URL
A View is the only controller type to posses a visual interface. All user interaction with Web Dynpro
Only
applications takes place through view controllers.
Windows
A Window (or more accurately, a “View Assembly”) defines the visual interface to a Web Dynpro
application. A window must contain at least one view, and will implement a component interface view.
There are two things to notice in the graphic above:
y Under the path <Component_name> Æ Component Interface Æ Interface Views, there is the entry
<Component_name>InterfaceView.
y Under the path <Component_name> Æ Windows, the name of the component has been repeated
Despite having different names, <Component_name> and <Component_name>InterfaceView are one
and the same entity. The Window name is programmatic entity referenced by the Web Dynpro
developer, and the Interface View name is the entity referenced by the Web Dynpro Framework.
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Custom Controllers
Custom controllers are used to encapsulate units of functionality that are shared by several controllers
and require no direct user interaction. A custom controller is always instantiated as a singleton with
respect to its parent component.
Internal
Only
situations that will optimize or simplify the architecture of your application.
The interface(s) that this single component presents to either the Web Dynpro Framework or the
embedding controller are defined as Component Interfaces. There is a one to one relationship between
a component interface view and a component window.
View controllers are used to provide a visual interface to a Web Dynpro application. In order for a view
to be seen on the screen, it must be embedded into a Window.
Other WD Required
Custom Controller
Controllers Controllers
Implementation
Custom Controller
Controller Context Standard
Interface
Hook
Root Node
Methods
Models Model Usage Instance
Methods
Internal
Only
Model Model
Object Object
Events
Other WD Component
Components Usage
Partner
Use
Created by explicit declaration Created by the
or coding Web Dynpro Framework (WDF)
SAP
SAP
SAP AG 2004
Partner
Use
When a Web Dynpro component is created, a special custom controller is created called the Component
Controller. It is this controller that drives the functionality of the entire component.
Only
All custom controllers are instantiated as singletons with respect to their parent component.
Custom controllers are instantiated automatically by the Web Dynpro Framework and the instantiation
order is undefined! Therefore, the coding in a custom controller should make no assumptions about the
existence of any other custom controller.
Other WD Required
View Controller
Controllers Controllers
Implementation Layout
Custom Controller
Controller Context Standard
Interface
Hook
Root Node
Methods
Models Model Usage Instance
Methods
Internal
Only
Model Model
Object Object
Actions
Use
Created by explicit declaration Created by the
or coding Web Dynpro Framework (WDF)
SAP
SAP
SAP AG 2004
Partner
Use
The lifespan of a view controller is determined by its presence in (or absence from) the current window
(The term “View Assembly” may also be used instead of the term “Window”). As soon as a view
controller instance is no longer part of the current view assembly, the Web Dynpro Framework will
Only
automatically garbage collect it.
View controllers are always instantiated as singletons with respect to their parent component. Therefore,
if the same view is embedded multiple times in a view assembly, you will see the same data in each
view.
LineItems LineItems
Description Description
Controller
ItemNo Usage ItemNo
Declaration
Price Price
Internal
Only
Quantity Quantity
OrderNo OrderNo
SalesDate SalesDate
Partner
SalesRep SalesRep
LongText LongText
Use
Web Dynpro Component
Mapped node collection Node collection of
SAP
Mapping
SAP
Partner
Use
Context Mapping
Context mapping allows a context node in one controller to be supplied automatically with data from a
corresponding context node in another controller. This is the primary mechanism for sharing data
between controllers.
Internal
Mapping Terminology
When two controllers within the same component share data through a mapping relationship, this is
known as “Internal Mapping”.
Only
The context node that acts as the data source is known as the “Mapping Origin Node”, and the context
node that is mapped is known as the “Mapped Node”.
There is also a type of mapping known as “External Mapping”, but this will not be dealt with in this
chapter.
Prerequisites
In order for a mapping relationship to be established, the following steps must first be performed:
y A node must exist in the context of the controller acting as the mapping origin. This node need not
have any declared child nodes or attributes.
y The mapping origin controller must be a custom controller.
y The controller containing the mapped node must declare the use of the mapping origin controller as a
required controller.
ItemNo ItemNo
Internal
Only
Price Price
Quantity Quantity
OrderNo OrderNo
Partner
SalesDate SalesDate
SalesRep SalesRep
Use
LongText LongText
SAP
SAP
SAP AG 2004
Partner
Use
Data Binding
Data binding is the means by which data is automatically transported from a view controller’s context to
a UI element in its layout.
Internal
You may not bind UI elements to context nodes or attributes that occur in some other controller. UI
elements are private to the view controller within which they are declared.
Only
The data binding process decouples the UI element object from the application code within the view
controller. Therefore, in order to manipulate UI element properties, the application code in the view
controller need only manipulate the values of context nodes and attributes to which the UI elements are
bound. The Web Dynpro Framework then manages the following two tasks:
y The transport of data from the context to the UI element during the screen rendering process.
y Repopulating the context from the UI element after data is entered by the user.
Window
View Set “Identify Customer“ View Set “Case Detail“
Empty
Customer
Search
Interaction
Record
Customer Product
Details Details
Internal
Only
Interaction
History
Customer Product Empty
List List
Partner
Use
z A window is the set of all possible views that can make up a visible screen
z A window can have zero or more view sets embedded within it.
z A view set is subdivided into several view areas each of which can possibly display
one or more views.
z A view area can only display one view at a time.
SAP
SAP
SAP AG 2004
Partner
Use
You can embed either a single view, or one or more view sets into a window. Each view set in turn is
Only
divided into view areas, each of which can have one or more views or view sets embedded within it.
A view area can only display one view at a time. Navigation links must be defined between views in
order for the contents of a view area to be replaced.
View areas can be blanked out by creating an empty view whose inbound plug responds to an
appropriate navigation event.
Window
View Set “Identify Customer“
Empty
Customer
Search
Internal
Only
Customer
List
Partner
Use
z The subset of views visible at any one time is known as a “View Assembly”
z Navigation causes either specific views within a view area to be replaced, or can
cause entire view sets within the window to be replaced.
SAP
SAP
SAP AG 2004
Partner
Use
View Assembly
Special asynchronous navigation events are the triggers that cause a view area to contain a particular
view.
Internal
For a given window definition in which multiple views are embedded into view areas, there could be
many permutations of views visible. The permutation that is visible depends on which navigation links
the user follows.
Only
The subset of views visible at anyone time is known as a “View Assembly”.
z To define the navigation between two views, you need to create exit and
entry points for each view using outbound and inbound plugs.
z Only then you can specify the navigation flow using navigation links
Internal
Only
Partner
Use
Choose Open Navigation Modeller
from the context menu
SAP
SAP
SAP AG 2004
Partner
Use
Navigation Modeller
The Navigation Modeller is a Web Dynpro specific, graphical editor in which you can define the
navigation links that exist between the different views of your Web Dynpro Component. The view that
displays the work area of the Navigation Modeller, and within which the individual elements are
Internal
Only
y Views
y Inbound and Outbound Plugs
y Navigation Links
Opening the Navigation Modeller
Start the Navigation Modeller either by choosing the context menu entry Open Navigation Modeller for
the window name in the Web Dynpro Explorer or by double clicking on the window name.
Navigation link
Internal
Only
Partner
Use
navigation links that exists between the different views in a window.
z The Web Dynpro Explorer shows the same information as a hierarchy
SAP
SAP
SAP AG 2004
Partner
Use
Outbound Plugs
Calling an outbound plug method causes a navigation event to be raised. Navigation events are special,
asynchronous events that are placed into a navigation queue. Only when all the outbound plugs have
been called by all the views in the current view assembly, will the Web Dynpro Framework enter its
Internal
navigation processing phase. Outbound plugs should be named according to the action that caused
navigation away from the current view.
Inbound Plugs
Only
Inbound plugs are special event handler methods that subscribe to navigation events raised when
outbound plugs are fired. Inbound plug methods are called only when the navigation queue is processed.
This will only take place once all the views in the current view assembly have fired their outbound plugs
and no validation errors have occurred that would cause navigation to be cancelled. Inbound plugs
should be named according to the reason for which the view being displayed.
Links
Outbound and inbound plugs are joined together using navigation links created in the Navigation Editor.
Select the Navigation Link tool from the graphical editor, then draw a line from the outbound plug to the
inbound plug. This causes the event handler method represented by the inbound plug to subscribe to the
navigation event raised by the outbound plug.
Internal
Only
Externally
Interface view
Visible
Internally
Controller
Interface
Partner
Visible
Interface
View
Use
Controller
Implements
Window Component
SAP
Controller
SAP
SAP AG 2004
Partner
Use
controller, and these methods can react to events raised by the parent component.
y The interface view is the standardized mechanism by which all view assemblies can be presented
through the generic Web Dynpro Framework. By means of the interface view, a component’s visual
Only
interface becomes a reusable unit, thus allowing you to embed it into a larger view set.
y A component may have zero or more interface views.
Internal
Only
Externally
Interface view
Visible
Internally
Controller
Interface
Partner
Visible
Interface
View
Use
Controller
Implements
Window Component
SAP
Controller
SAP
SAP AG 2004
Partner
Use
In the same way that the functionality in an ABAP module pool can be accessed by defining multiple
transaction codes, so the functionality of a single Web Dynpro component can be accessed by defining
multiple applications.
Only
Application definition
In order to define a Web Dynpro application, you must specify
y The component to be invoked. This component is then known as the “root” component,
y Which interface view of the root component will be used as the initial view assembly,
y Which inbound plug will act as the entry point for the nominated interface view (this inbound plug
must have the Startup check box selected)
Component A
Internal
Only
Use
z Comp. E: Child component with respect to comp. D
z Comp. A, B, E: Accessible as distinct Web Dynpro Applications
SAP
SAP
SAP AG 2004
Partner
Use
application.
After a suitable usage declaration has been made, any Web Dynpro Component can act either as a parent
component (embedding the functionality of some other component), or it can act as a child component
Only
(being embedded by another component).
Advantages of a component based architecture:
y The Web Dynpro application is divided into interacting elements.
y The structure of a large Web Dynpro application is clearer.
y Working with reusable elements saves development costs and time.
y The parent Web Dynpro component does not need to have any knowledge of the internal structure of
the child component; it need only know how to drive the child component’s interface.
Externally Visible
Controller
Internally Visible
Interface
Interface z Created by the Model
View Wizard
Controller
z Components use
declarations
models via an explicit
Usage
Component
usage declaration
Controller
Internal
Only
Components
Usage z Model Types:
declarations
Custom Controller
Adaptive RFC
Model 1
Web Service
View
Partner
Use
Component Models
Programmatic Entities
SAP
SAP
SAP AG 2004
Partner
Use
By means of the Common Model Interface (CMI) all the different types of external services are given a
uniform interface. It is now of little importance for the Web Dynpro application to know how the model
functions internally. All that is important is that the Web Dynpro controller is able to supply the correct
Only
information to drive the model’s functionality.
Web Dynpro Models are independent from any particular component.
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
1 Development Objectives
Partner
Use
“Welcome to Web Dynpro”. This text will then be displayed on the user’s browser.
SAP
SAP
2 Result
After this exercise is complete, you
should see the result shown on the left.
Partner
Use
Internal
3 Prerequisites
You have launched the SAP NetWeaver Developer Studio.
You have selected the Web Dynpro Perspective.
4-1 Create a new Web Dynpro project called JA310_Ex_1. Without changing any other
values, press Finish.
4-2 In the Web Dynpro project, create a new component having the following values:
Name: Ex1Comp
Package: com.sap.training.wd.ex1
Window Name: Ex1Comp
View Name: Ex1View
4-3 In the Web Dynpro Explorer locate the view controller Ex1View under the Views node.
- Open the view editor and select the Layout tab.
- In the outline view, select the RootUIElementContainer.
Internal
Only
You should see its properties appear in the bottom right tabbed window. If the
properties do not appear after the UI element has been selected, then click on the
Properties tab in the bottom right window.
4-4 Change the layout property of the RootUIElementContainer from FlowLayout to
MatrixLayout.
Partner
4-5 Now in the Outline view select the element DefaultTextView and change the design
property from standard to header1.
Use
Notice that the appearance of the text changes.
4-6 In the Outline view again, right mouse click on RootUIElementContainer. - Select
Insert Child.
- From the Type drop down list, select TextView. The Id of the field will
SAP
SAP
Partner
Use
Ex1View. This text is in the wrong place, so we will move it to the start of the next
row.
Only
- Change the layoutdata property of TextView1 from MatrixData to
MatrixHeadData.
- Change the design property from standard to header2.
4-8 Save your metadata by clicking on the toolbar icon that contains a circle with the letter
M and a floppy disk.
4-9 Lastly, we must create an application so that we can access the Web Dynpro
component via a URL.
- In the Web Dynpro Explorer, right mouse click on the Application
node immediately under the Web Dynpro node.
- Select Create Application from the context menu. Create the
application having the following attributes:
Name: Ex1App.
Package: com.sap.training.wd.ex1
Deploy and start the application: Right mouse click on the newly created application Ex1App
and select Deploy new archive and run. This will first save your metadata, then rebuild the
project, then create an Enterprise Archive file, and finally deploy it to the defined J2EE
engine.
When you deploy an application for the first time since starting the NetWeaver Design
Studio, you will be asked for the Software Deployment Manager password. The default
value is sdm.
Internal
Only
Partner
Use
SAP
SAP
Partner
Use
Internal
Only
4 Overview: Developing
Internal
Only
Use
SAP
SAP
Partner
Use
Internal
Only
4-2 In the Web Dynpro project, create a new component.
Internal
Only
Partner
4-3 In the Web Dynpro Explorer locate the view controller Ex1View under the Views node.
Use
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
Use
4-5 Now in the Outline view select the element DefaultTextView and change the design
SAP
SAP
Partner
Use
Internal
Only
4-6 In the Outline view again, right mouse click on RootUIElementContainer and select
Insert Child….
Internal
Only
Use
Change the design property from standard to
header2.
SAP
SAP
4-8 Save your metadata by clicking on the toolbar icon that contains a circle with the letter
M and a floppy disk.
Partner
Use
Internal
Only
4-9 Lastly, we must create an application so that we can access the Web Dynpro
component via a URL.
Internal
Only
Use
application Ex1App and select Deploy new archive
and run. This will first save your metadata, then
rebuild the project, then create an Enterprise
SAP
Archive file, and finally deploy it to the defined
SAP
J2EE engine.
Partner
Use
Only
Contents:
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Use
View
SAP
SAP
SAP AG 2004
Partner
Use
design paradigm was with the release of the Smalltalk-80 programming language.
MVC was a revolutionary design paradigm because it was the first to describe software components in
terms of:
Only
y The functional responsibilities each should fulfil.
y The message protocols to which each component should respond.
SAP has modified and extended the original MVC specification in order to create the Web Dynpro
toolset.
Externally
Visible
Interface view
Controller
Interface
Internally
Visible
Interface
View
Controller
Implements
Usage declarations
Window Component
Internal
Only
Controller
Contains
Components
Usage
declarations
Custom Controller
Model 1
Partner
View View
Layout Controller
Use
Model 2
W e b D y n p r o C o m p o n e n t Models
Visual Entities Programmatic Entities
SAP
SAP
SAP AG 2004
Partner
Use
y Standard MVC allows for nested view controllers. This is not permitted in Web Dynpro.
y SAP has extended the design concept by adding an aggregation unit known as a component. The
component is both the unit of application development and application reuse.
Only
Externally
Visible
Interface view
Controller
Interface
Internally
Visible
Interface
View
Controller
Implements
Usage declarations
Window Component
Internal
Only
Controller
Contains
Components
Usage
declarations
Custom Controller
Model 1
Partner
View View
Layout Controller
Use
Model 2
W e b D y n p r o C o m p o n e n t Models
Visual Entities Programmatic Entities
SAP
SAP
SAP AG 2004
Partner
Use
y All controllers are independent programs yet none function in isolation from the other controllers in
the component.
y All controllers (apart from an Interface View Controller) store their runtime data in a hierarchical data
Only
storage area known as the Context.
y Unless an explicit controller usage is declared, all the data in a controller’s context is private.
y A custom controller may share the data in its context, but a view controller may not.
Externally
Visible
Interface view
Controller
Interface
Internally
Visible
Interface
View
Controller
Implements
Usage declarations
Window Component
Internal
Only
Controller
Contains
Components
Usage
declarations
Custom Controller
Model 1
Partner
View View
Layout Controller
Use
Model 2
W e b D y n p r o C o m p o n e n t Models
Visual Entities Programmatic Entities
SAP
SAP
SAP AG 2004
Partner
Use
y All controllers are independent programs yet none function in isolation from the other controllers in
the component.
y All controllers (apart from an Interface View Controller) store their runtime data in a hierarchical data
Only
storage area known as the Context.
y Unless an explicit controller usage is declared, all the data in a controller’s context is private.
y A custom controller may share the data in its context, but a view controller may not.
Controller
Other WD Required
Controllers Controllers
Implementation
Controller
Custom Standard Context
Controller Interface
Hook
Root Node
Methods
Models Model Usage Instance
Methods
Internal
Only
Model Model
Object Object
Events
Other WD Component
Partner
Components Usage
Use
Created by explicit declaration or coding Created by the Web Dynpro Framework (WDF)
SAP
SAP
SAP AG 2004
Partner
Use
Only
use of another custom controller.
y You may not specify the name of a view controller as a required controller as this would violate good
MVC design principles. A view controller should be written such that it is responsible for nothing
more than the display of data and user interaction. A view controller is not responsible for generating
the data it displays: that is the role of a custom controller.
Required
Controller
Other WD
Controllers Controllers
Implementation
Controller
Custom Standard Context
Controller Interface
Hook
Root Node
Methods
Models Model Usage Instance
Methods
Internal
Only
Model Model
Object Object
Other WD Component
Partner
Components Usage
Use
Created by explicit declaration or coding Created by the Web Dynpro Framework (WDF)
SAP
SAP
SAP AG 2004
Partner
Use
After a model has been created, it’s use must be explicitly declared on a per component basis.
Only
Required
Controller
Other WD
Controllers Controllers
Implementation
Controller
Custom Standard Context
Controller Interface
Hook
Root Node
Methods
Models Model Usage Instance
Methods
Internal
Only
Model Model
Object Object
Other WD Component
Partner
Components Usage
Use
Created by explicit declaration or coding Created by the Web Dynpro Framework (WDF)
SAP
SAP
SAP AG 2004
Partner
Use
The component usage instance must be given a new name in the same way that an instance of a Java
class has a different name from the class being instantiated.
Only
Lifespan
The lifespan of a component usage instance cannot exceed the lifespan of the parent component.
When a component usage instance is created, the lifespan property must be given a value. If this is set to
“createOnDemand”, then the Web Dynpro Framework will create the component usage instance
automatically. If however, it is set to “manual”, then it is the responsibility of the application
programmer to explicitly instantiate the component usage instance.
Required
Controller
Other WD
Controllers Controllers
Implementation
Controller
Custom Standard Context
Controller Interface
Hook
Root Node
Methods
Models Model Usage Instance
Methods
Internal
Only
Model Model
Object Object
Other WD Component
Partner
Components Usage
Use
Created by explicit declaration or coding Created by the Web Dynpro Framework (WDF)
SAP
SAP
SAP AG 2004
Partner
Use
Code Implementation
Each Web Dynpro controller is a separate Java program. The definition of these programs is generated
automatically when a new component or controller is declared. The source code, that implements these
controllers is generated automatically. You are provided with various points within the controller code
Internal
Only
Controller code is regenerated every time the “Implementation” tab is entered.
Standard Hook Methods
In every controller, there are certain standard methods that are always present. At controller creation
time, these methods are empty and can hold any coding the developer wishes to place within them.
The application developer is not permitted to deleted or rename any of these standard hook methods. If
any attempt is made to do this, the changes will be lost when the coding is regenerated.
Internal
Only
Use
z Irrespective of whether you choose to implement code within these methods,
each will be called once during the controller’s lifecycle.
SAP
SAP
SAP AG 2004
Partner
Use
wdDoInit()
Standard hook method for all Web Dynpro controllers. This method is only called once during the
lifecycle of a controller. All your initialization code should go here since this method is called
immediately after the controller has been instantiated.
Internal
The application developer has no access to the Java constructor of any Web Dynpro controller class. All
Web Dynpro controllers have a constructor with a signature of {nctl}(IPrivate{nctl} wdThis)
Only
where {nctl} is the name of the controller.
wdDoExit()
Standard hook method called at the end of a controller’s life cycle. All your cleanup code should go
here.
This method is called immediately before the controller’s lifecycle comes to an end.
Required
Controller
Other WD
Controllers Controllers
Implementation
Controller
Custom Standard Context
Controller Interface
Hook
Root Node
Methods
Models Model Usage Instance
Methods
Internal
Only
Model Model
Object Object
Other WD Component
Partner
Components Usage
Use
Created by explicit declaration or coding Created by the Web Dynpro Framework (WDF)
SAP
SAP
SAP AG 2004
Partner
Use
Important: Instance methods created through the NetWeaver Development Studio may not be
overloaded. This is because the Web Dynpro metamodel is designed to be independent of the
Only
implementation language. Since the Web Dynpro toolset has also been developed for use in Object
Oriented ABAP which does not support method overloading, this feature has not been implemented in
Web Dynpro for Java.
/*
* The following code section can be used for any Java code that is
* not to be visible to other controllers/views or that contains
* constructs currently not supported directly by Web Dynpro (such
* as inner classes or member variables etc.). </p>
*
* Note: The content of this section is in no way managed/controlled
* by the Web Dynpro Designtime or the Web Dynpro Runtime.
*/
Internal
Only
//@@begin others
//@@end
z At the end of the source code listing for every controller, there is a section
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
y Since the view controller’s standard hook method wdDoModifyView() is static, if you want it to
call any utility methods these methods must also be static. Such static, user defined method can only
be defined here!
Only
// IMPORTANT NOTE
// ALL_ IMPORT STATEMENTS MUST BE PLACED IN THE FOLLOWING SECTION
// ENCLOSED BY @@begin imports AND @@end. FURTHERMORE, THIS SECTION
// MUST ALWAYS CONTAIN AT LEAST ONE IMPORT STATEMENT (E.G. THAT FOR
// IPrivateDynamicsAppInterface).
// OTHERWISE, USING THE ECLIPSE FUNCTION "Organize Imports"
// FOLLOWED BY A WEB DYNPRO CODE GENERATION (E.G. PROJECT BUILD)
// WILL RESULT IN THE LOSS OF IMPORT STATEMENTS.
Internal
Only
//@@begin imports
import com.sap.wd.dynamics.wdp.IPrivateDynamicsAppInterface;
//@@end
Partner
Use
Eclipse “Organize Imports” function.
SAP
SAP
SAP AG 2004
Partner
Use
Controller Imports
y Standard import statements are at the top of all controller implementations.
y The code generator places all import statements here.
y If you reference a class that does not yet have an import statement, then use the Eclipse function
Internal
Only
Internal
Only
this.wdControllerAPI = wdThis.wdGetAPI();
this.wdComponentAPI = wdThis.wdGetAPI().getComponent();
}
z Within any Web Dynpro controller, three shortcut variables are always
Partner
present, whose values are all derived from the member variable
wdThis.
z The member variable wdThis is populated from a parameter of the same
Use
name, passed in by the Web Dynpro Framework when the controller is
instantiated.
SAP
SAP
SAP AG 2004
Partner
Use
wdThis
wdThis is the Web Dynpro specific self reference and should be used in preference to the standard Java
self reference of this. wdThis is a reference to the current controller’s IPrivate{nctl} interface
and represents all the functionality implemented in the generated class Internal{nctl}. This gives
Internal
you access to standard Web Dynpro functionality such as logging, validation, and parameter mapping.
The only situation in which the use of the standard Java self reference this is appropriate is, when you
Only
wish to make explicit reference to declarations made between the comment markers //@@begin
others and //@@end. Any variables or methods declared here are invisible to the Web Dynpro
Framework.
wdContext
wdContext is the reference to the controller’s context root node, and thus to the entire context.
wdControllerAPI
wdControllerAPI is the reference to the API of the current controller – be it a custom controller or a
view controller.
wdComponentAPI
wdComponentAPI is the reference to the API of the component controller to which this controller
belongs. Remember that the component controller is considered hierarchically superior to all other
controllers in the component.
If this variable is used from within the component controller itself, then wdComponentAPI and
wdControllerAPI will point to the same object.
Externally
Visible
Interface view
Controller
Interface
Internally
Visible
Interface
View
Controller
Implements
Usage declarations
Window Component
Internal
Only
Controller
Contains
Components
Usage
declarations
Custom Controller
Model 1
Partner
View View
Layout Controller
Use
Model 2
W e b D y n p r o C o m p o n e n t Models
Visual Entities Programmatic Entities
SAP
SAP
SAP AG 2004
Partner
Use
Custom controllers
These are the internal building blocks of a Web Dynpro component and have no user interface. They
are only to be used when some unit of functionality is required by several other controllers. For
instance, a custom controller could be used, when a BAPI is called, and the information returned requires
Internal
some sort of intermediate processing before it can be displayed. This custom controller could then be
declared for use by several different view controllers.
Only
Do not create a custom controller simply because you can! Only use one where its presence will simplify
or optimize the component’s architecture.
Component Controller
The component controller is a special custom controller that is automatically created when a component
is created. The lifespan of a component is defined by, and equal to, the lifespan of the component
controller.
Lifespan
All custom controller instances exist for as long as their parent component exists and are instantiated
automatically by the Web Dynpro framework. After the component controller has been instantiated, the
order in which any subsequent custom controllers are instantiated is undefined.
An Interface controller exists for as long as the component usage instance exists.
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
wdDoPostProcessing()
This standard hook method is found only in component controllers.
In complex Web Dynpro applications, it is possible that the data from multiple components must be
validated before the next step in the business process can be taken. This method has been implemented
Internal
Only
Whenever an outbound plug is fired from a view controller, a navigation event is raised. It is perfectly
possible for each view in a viewset to fire an outbound plug; therefore, all navigation events are placed
into a queue and are only processed once all the views in the current view assembly have been
processed. The wdDoBeforeNavigation() method is called just before the Web Dynpro
Framework processes the events in the navigation queue. This allows you to implement your own coding
to do such things a navigation event prioritisation etc.
The isCurrentRoot parameter
When a component‘s interface view is nominated to be the initial screen seen by the user, then the
component containing that interface view is known as the root component. Since the
wdDoPostProcessing() method can be found in all component controllers, it is necessary to
identify whether the current invocation occurs in the component controller of a root component or not.
Required
Custom Controller
Other WD
Controllers Controllers
Implementation
Controller
Custom Standard Context
Controller Interface
Hook
Methods Root Node
Internal
Only
Model Model
Object Object
Events
Other WD Component
Partner
Components Usage
Use
Created by explicit declaration or coding Created by the Web Dynpro Framework (WDF)
SAP
SAP
SAP AG 2004
Partner
Use
runtime.
A typical use of such events is the invocation of processing in a view controller after processing in the
Only
component controller has been completed. This can be achieved when a method in the view controller
subscribes to an event raised by the component controller.
Important: If two or more methods subscribe to the same event, then the order in which they will be
executed is undefined.
Externally
Visible
Interface view
Controller
Interface
Internally
Visible
Interface
View
Controller
Implements
Usage declarations
Window Component
Internal
Only
Controller
Contains
Components
Usage
declarations
Custom Controller
Model 1
Partner
View View
Layout Controller
Use
Model 2
W e b D y n p r o C o m p o n e n t Models
Visual Entities Programmatic Entities
SAP
SAP
SAP AG 2004
Partner
Use
View controllers
A view controller is visual building block of a Web Dynpro component and is designed to handle all
aspects of data display and user interaction.
Interface View Controller
Internal
Interface view controllers are very similar to view controllers – but with an important restriction. An
interface view controller is executed as a Java interface by the calling controller (usually the Web
Dynpro Framework). Consequently, an interface view controller has neither its own context, nor any of
Only
the standard hook methods.
Lifespan
A view controller’s lifespan parameter can have the values When Visible or Framework Controlled. A
view instance will be created either because it is the default view in a view area; or when the first
navigation request to that view is encountered. There are three situations is which the view instance can
be deleted.
y If When Visible is selected, then the view will be deleted when a navigation event replaces the current
view area with some other view, and the view is no longer part of the current view assembly.
y If Framework Controlled is selected, then the view will be deleted when there is no further use for the
view. This will never occur whilst the view is part of the current view assembly.
y Finally, a view controller will never exist for longer than the lifespan of its parent component
controller.
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
wdDoModifyView()
This Standard Hook method is called just before the view layout is rendered. It is the only method in
which the programmer is allowed direct access to the UI element objects themselves.
Internal
It is a static method to prevent programmers from storing references to UI elements in the view
controller class – this would violate the principles of good MVC design!
Only
Notice in above code sample that the name of the view controller has been generalised to {nv}. This
means the parameters wdThis and wdContext are of type IPrivate{nv}. Obviously, when you
edit this method in the NetWeaver Development Studio, you will see the name of your view controller,
not {nv}.
The firstTime parameter is a boolean value that lets you know if the screen is being rendered for the
very first time, or re-rendered in response to an Action event.
Required
View Controller
Other WD
Controllers Controllers
Implementation Layout
Controller
Custom Standard Context
Controller Interface
Hook
Root Node
Methods
Models Model Usage Instance
Methods
Internal
Only
Model Model
Object Object
Actions
Use
Created by explicit declaration or coding Created by the Web Dynpro Framework (WDF)
SAP
SAP
SAP AG 2004
Partner
Use
y An action is an event that originates on the client, initiates an HTTP round trip, and is then handled on
the server side by a special event handler found only in a view controller.
y Many different UI elements are able to trigger an action, e.g, the onAction event of a button UI
Only
element.
Required
View Controller
Other WD
Controllers Controllers
Implementation Layout
Controller
Custom Standard Context
Controller Interface
Hook
Root Node
Methods
Models Model Usage Instance
Methods
Internal
Only
Model Model
Object Object
Actions
Use
Created by explicit declaration or coding Created by the Web Dynpro Framework (WDF)
SAP
SAP
SAP AG 2004
Partner
Use
Outbound plugs
A navigation event is raised when an outbound plug is fired.
Only
Using the generic name {npo} for an outbound plug, its declaration will cause a method to be generated
in the view’s component controller called wdFirePlug{npo}().
Inbound plugs
An inbound plug is the navigation event handler that will respond when the fired event.
Using the generic name {npi} for an inbound plug, its declaration will cause a method to be generated
in the view’s component controller called onPlug{npi}().
Navigation Links
A link defines which onPlug{npi}() methods will subscribe to the navigation event raised when
method wdFirePlug{npo}() is called.
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Contents:
z The Structure of the Context
z Context Mapping
z Internal mapping
z External mapping
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Controller
Other WD Required
Controllers Controllers
Implementation
Controller
Custom Standard Context
Controller Interface
Hook
Root Node
Methods
Models Model Usage Instance
Methods
Internal
Only
Model Model
Object Object
Other WD Component
Components Usage
Partner
Use
Created by explicit declaration or coding Created by the Web Dynpro Framework (WDF)
SAP
SAP
SAP AG 2004
Partner
Use
The Context
Every Web Dynpro controller (except an interface view controller) has exactly one hierarchical data
storage structure known as a context. The data held in the context exists only for the lifespan of the
controller. Once the controller instance has been terminated, all data held within its context is lost.
Internal
Context structure
The structure (I.E., the metadata) of a context will typically be defined at design time; however, at
runtime, it is perfectly possible not only to modify the contents of the context, but also to modify its
Only
structure.
Data visibility
Unless declared to be otherwise, all runtime data within a controller’s context is private to that
controller.
Sharing data between different controllers
Information held in the context of a custom controller can be made accessible to the context of another
controller (view or custom) by a technique known as context mapping. Using this technique, two or
more controllers can access the same runtime data. This is the primary mechanism for sharing data
between controllers within a single component.
It is not permitted for a view controller to share its context data.
Internal
Only
Partner
Use
3) Make the Properties View
visible to show the properties of
the selected Context elements.
SAP
SAP
SAP AG 2004
Partner
Use
Context Editor
The Context Editor is a Web Dynpro specific graphical editor that shows the hierarchical structure of a
controller’s context. Using the Context Editor you can create the various different nodes and attributes
from which a context is constructed.
Internal
Important: You should always have the Properties View open when you edit the context because there
are certain properties that will critically affect the behaviour of the context at runtime (namely,
Only
Cardinality and Singleton). If these properties are incorrectly set, then at runtime you can arrive at the
false impression that data is missing from the context!
Model Attribute
Context Root Node
Internal
Only
z Value Node:
Stores runtime data or references to runtime data stored in value nodes of other
Partner
controllers
Metadata description declared manually or derived from a Java Dictionary Structure
z Model Node:
Use
Stores references to model objects that hold the actual runtime data.
Must be bound to a model object. The model object then supplies all the metadata
necessary for the context to have a full description of the data it holds.
SAP
SAP
SAP AG 2004
Partner
Use
Context Structure
All controller contexts are constructed from a hierarchical arrangement of entities known as nodes and
attributes. A context always has a parent node known as the Root Node. The root node is created
automatically when the controller is initialised and always has the same properties.
Internal
Important: The context root node may not be deleted or modified in any way!
Nodes
A context node is the main abstraction class used for runtime data storage within the Web Dynpro
Only
Framework. Context nodes are arranged hierarchically and are permitted to have children. The node may
have attributes or other nodes as children.
All the child entities of a node are aggregated into a unit known as an element. A node can then be
thought of as a collection of such elements in the same way that a table is a collection of rows.
The maximum and minimum number of elements permitted in a node collection is controlled by the
cardinality property.
All nodes contain an element collection, even if the maximum number of elements within the collection
is limited to one.
Attributes
An attribute is a hierarchical entity within the context that is not permitted to have children. A context
attribute cannot exist without being the child of some parent node – be it the context root node itself, or
some other node.
Internal
Only
Price
z Any node or attribute that has the
Quantity
context root node as its immediate
OrderNo
parent, is known as an independent
SalesDate node or attribute.
Partner
Use
known as a dependent node or
attribute.
Design time
SAP
SAP
SAP AG 2004
Partner
Use
Context Terminology
The nodes or attributes that have the context root as their immediate parent are referred to as being
independent because their existence is independent of any developer action. Any such nodes or
attributes will automatically exist at runtime because their parent node (the context root node) is
Internal
However, nodes or attributes that have some other node as their parent are referred to as being
Only
dependent because they must be created by specific application code. In other words, their existence is
dependent upon you, the developer, writing the appropriate code to instantiate these objects.
Context Metadata
Node Metadata (c=cardinality, s=singleton)
Context Root (c=1..1, s=true)
IWDNodeInfo object
SalesOrders (c=0..n, s=true) Attribute Metadata (data type)
LineItems (c=0..n, s=false) IWDAttributeInfo object
Description (string) A node collection
ItemNo (int)
Internal
Only
Price (decimal)
z All context nodes are collections.
Quantity (decimal)
z A node collection is composed of
OrderNo (int)
elements, where an element is an
SalesDate (date)
Partner
Use
number of elements a node collection
may hold at runtime.
Design time
SAP
SAP
SAP AG 2004
Partner
Use
collections, so there could potentially be multiple instances of each child node and attribute within a
node’s collection.
The Cardinality Property
Only
Every context node has a property called Cardinality. This property is composed of two values that
taken together, describe the maximum and minimum number of elements the node collection may hold
at runtime.
y Cardinality Minimum: 0 or 1
y Cardinality Maximum: 1 or n
Therefore, there are four possible cardinality values (specified as <Min>..<Max>)
y 0..1 Zero or one elements permitted
y 0..n Zero or more elements permitted
y 1..1 One and only one element permitted
y 1..n One or more elements permitted
c=1..1, s=true
= Element created by an application at runtime
Default 0 = Element created by the WDF at context initialisation time
Element
Internal
Only
c=1..1, s=true
Node collection contains a default element.
Default 0
Partner
Use
0
Can contain a maximum of one element.
Independent Node
SAP
SAP
SAP AG 2004
Partner
Use
If you attempt to perform any action on a node collection that would violate its cardinality, then you
will get a runtime error from the Web Dynpro Framework. Such actions would be: trying to delete the
default element from a node of cardinality 1..<something>, or trying to add a second element to a node
Only
of cardinality <something>..1.
c=1..1, s=true
= Element created by an application at runtime
Default 0 = Element created by the WDF at context initialisation time
Element = Element at the lead selection
Internal
Only
c=1..n, s=true
Node collection contains a default element.
..n Can contain as many elements as required.
Partner
1
c=0..n, s=true Default 0
Element
..n
Use
1
0 Independent Node
Node collection is initially empty.
Can contain as many elements as required.
Independent Node
SAP
SAP
SAP AG 2004
Partner
Use
Only
multiple elements as being selected (controlled by the selection cardinality property), but only one of the
selected elements can be processed at any one time. The element being processed is referred to as the
lead selection element.
Internal
Only
Quantity (decimal)
LineItems
OrderNo (int)
LineItems ItemNo ..n
SalesDate (date) ItemNo
Price 1
LineItems
Partner
ItemNo ..n
SalesRep (string) ItemNo
Price 0
ItemNo
Price 1
ItemNo ..n Price
LongText (string) ItemNo
Price 0
ItemNo
Price 1
Use
ItemNo Price
Price 0
Price
SAP
SAP
SAP AG 2004
Partner
Use
The Boolean property called Singleton critically affects the relationship between an dependent node and
its parent node!
Node LineItems as a non-singleton (Singleton = false)
Only
If the node LineItems has its Singleton property set to false, then for every element in the parent node
collection (SalesOrders in this case), there will be a distinct instance of the child node LineItems.
The most important thing to understand here is that each instance of node LineItems is related to the
respective element in the parent node collection. Notice that the arrows pointing to each of the
LineItems node collections originate from each element in the parent node.
Therefore, if there are n elements in the parent node, then there will be n distinct instances of a non-
singleton child node.
Internal
Only
Quantity (decimal)
OrderNo (int)
SalesDate (date)
LineItems
Partner
SalesRep (string)
ItemNo ..n
LongText (string)
ItemNo
Price 1
Use
ItemNo
Price 0
Price
SAP
SAP
SAP AG 2004
Partner
Use
The most important thing to understand here is that a singleton node is related to its parent node
collection. Notice that the arrow pointing to the LineItems node collection originates from the entire
Only
SalesOrders node collection, and not from any element within the collection.
Repopulating singleton child nodes
In the above example, there could be many different elements in the SalesOrders node collection.
However, since there is only ever one instance of the singleton child node LineItems, we need to
ensure that when this child node is accessed, it contains the correct data for the selected element in the
parent node. In other words, if node SalesOrders contains the header records for orders 1000, 1001
and 1002; then there must be a way of ensuring the when order 1001 is being accessed, I don’t end up
with the node LineItems containing the data for order 1000!
Supply functions
Supply functions are the mechanism to repopulate child nodes when the lead selection in the parent node
changes. When a singleton child node is declared, you must also write an accompanying supply function.
The Web Dynpro Framework will then automatically call your supply function when the lead selection
in the parent node changes.
Internal
Only
Use
consume significantly less memory. ItemNo
Price 0
Price
SAP
SAP
SAP AG 2004
Partner
Use
information only when it is needed, rather than to read all the line items for all the sale orders in the hope
that the user might want to look at the information! This would be a highly inefficient application
architecture both in terms of processing requirements and memory usage.
Only
Lazy Data Access
Web Dynpro follows the principle of Lazy Data Access. This means that data is only obtained when it is
actually needed. When this principle is applied to the architecture of the context, it means that unless the
program actually needs to look at the data in a child node, then that child node will remain unprocessed.
Hence, there is no need to hold multiple instances of data the user has not requested.
Having singleton child nodes greatly reduces the amount of memory required for a business application,
and means that the Web Dynpro application does not waste time by performing unnecessary processing
on business data the user does not want to see.
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
z Advantages:
Internal
Only
task
Use
SAP
SAP
SAP AG 2004
Partner
Use
Context Mapping
Context mapping allows a controller (typically a view controller) to access data that has been pre-
processed by some other controller. Since a mapping relationship allows a direct reference to be made to
data in another controller, there is no need for this data to be copied or moved.
Internal
Important: A mapped node ceases to maintain its own element collection! Instead, it references the
element collection of the mapping origin node.
Only
Why can a view controller not act as a data source for a mapping relationship?
According to the principles of good MVC design, a view controller should be written in such a way that
it takes no part in the generation of the data it displays. Instead, the view controller should only be
concerned with displaying pre-generated data and then handling the resulting user interaction (validation
and error handling etc.).
It is the custom controller’s job to interact with model objects to generate the required data. Once the
data has been generated, the custom controller then supplies it to a view controller for display.
If a view controller were allowed to act as the data source (origin) for a mapping relationship, then the
situation could be created in which a custom controller was dependent upon functionality found in a
view controller. This would be bad MVC design and is therefore not permitted.
Double click on
Internal
Only
Use
Double click or
choose Open Data Modeler
from the context menu
SAP
SAP
SAP AG 2004
Partner
Use
Data Modeller
The Data Modeller is a Web Dynpro specific, graphical tool for modelling component and controller
usage within a component. Data links can be created that define a context mapping relationship between
two controllers. The perspective area that displays the Data Modeller is the Diagram View.
Internal
Only
Data Link
Once a data link has been created, double click on it, and you will see the Context mapping window pop-
up. Here you can drag a context node from the right hand side (the mapping origin) to the left hand side
(the context that will contain the mapped node). This does three things for you:
y It declares the controller containing the mapping origin as a required controller for the controller
containing the mapped node.
y It creates the node in the target context
y It establishes the mapping relationship.
y These steps can all be performed manually through the Context Editor if required.
Price Price
Internal
Only
Qty Qty
OrderNo OrderNo
SalesDate SalesDate
Partner
SalesRep SalesRep
LongText LongText
Use
W
W ee bb D
D yy nn pp rr oo C
C oo m
m pp oo nn ee nn tt
SAP
SAP
Mapping Relationship
SAP AG 2004
Partner
Use
There is however, one special case where a mapping relationship can only be partially established when
writing the current component. This is known as External mapping. As the name implies, this is a
Only
situation in which the mapping origin node lies outside the boundaries of, or is external to, the current
component.
Internal
Only
ShowAsTable SomeNode
External mapping is only possible for SomeChildNode
nodes in a Component Interface UpdateAllowed
AnAttribute
Controller.
Partner
AnotherAttribute
The mapped node must have its
isInputElement property set to
true.
Use
Web Dynpro Child Component
SAP
SAP
Relationship
SAP AG 2004
Partner
Use
External Mapping
There is a fundamental problem when trying to establish a mapping relationship with a mapping origin
node that lies outside the boundaries of the current component. The problem is simply this:
At the time the child component is being written, you have no idea what the identity of the mapping
Internal
origin node will be. In fact, you have no idea whether the component that will act as the parent even
exists!
Only
In order to get around this problem, context nodes in an Interface Controller have a special property
called isInputElement. You will not find this property on any other node in any other context!
The completion of the mapping relationship will have to be postponed until the parent component
declares a usage instance of this child component.
Context Root
Context Root
DataFromParent
DataToChild
Internal
Only
SalesOrderNo
SalesOrderNo
ShowAsTable
ShowAsTable
UpdateAllowed
UpdateAllowed
Partner
WD Child Component
Use
Web Dynpro Parent Component
SAP
SAP
Relationship
SAP AG 2004
Partner
Use
Only
has into the child component is through the child’s component interface controller. This is the controller
that contains the node with the isInputElement flag set to true. Therefore, in order to complete the
usage declaration, a context node in the parent component must be nominated to act as the mapping
origin.
External mapping relationships are usage specific!
Since it is possible to create multiple usages of the same child component, it therefore follows that each
child component usage instance could have a different context node nominated to complete the external
mapping relationship.
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
1 Development Objectives
Use
This exercise has the following objectives:
- Make the data stored in the context of the component controller available to a view
controller.
SAP
SAP
- Create some UI elements on the view layout that can display the data in the context of the
view controller.
The context of the component controller will act as the data source. Then using context
mapping, the data will be shared with a view controller. Once the data is available to the
Partner
Use
context of the view controller, UI elements can be added to the view layout. These UI
elements will then be bound to the context of the view controller.
Internal
2 Result
Only
In this exercise, you will extend the
component you created in the last exercise
to include two input fields and a push
button.
3 Prerequisites
You have launched the SAP NetWeaver Developer Studio.
You have selected the Web Dynpro perspective.
Internal
Only
Use
SAP
SAP
Partner
Use
Internal
Internal
Only
- Press Finish.
Now that the context mapping between the view controller and the component
controller is complete.
4-3 Open the outline view of the view Ex1View.
Partner
Use
4-4 Add a Label UI element and an InputField UI element for each of the attributes in the
PeopleInfo context node by using the Apply Template functionality:
- In the Outline view window, right mouse click on the
RootUIElementContainer UI element and select Apply Template from
SAP
SAP
Partner
Use
4-5 Even though we have not completed the development of the application, select Deploy
New Archive and Run from the right mouse-click menu on the application Ex1App.
The problem is that you can type into the input fields, but we cannot send the data
back to the server. The next few steps will rectify that problem.
Internal
4-6 In the view editor for view controller Ex1View, select the Actions tab.
- Define a new action, having the Name DataEntry and the text “Go”.
Only
4-7 Now go back to the layout tab of the view.
- In the Outline view, add a button as a child element of the
RootUIElementContainer.
- Select the Properties tab from the bottom window and change the
value of the button’s layoutdata property from MatrixData to
MatrixHeadData.
- Locate the onAction property of the button and assign the action
DataEntry from the drop down list.
Notice that the text on the button is defined by the text in the Action object.
The screen now has a button on it with the text Go. When this button is pushed, a round trip
to the server will take place and the data you entered in the input fields will be stored in the
respective context attributes.
Internal
Only
Partner
Use
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
Use
SAP
SAP
Partner
Use
Only
New -> Value Attribute. Enter the name FirstName
and press Finish.
Internal
Only
Use
We have just defined a value node in the context of
the component controller. We now need to share
this runtime information with the view controller.
SAP
Select the arrow icon from the toolbar on the upper
SAP
Partner
This will open a pop-up window called Edit
Use
Context Mapping.
The Edit Context Mapping window is divided into
two, vertical halves. On the right side is the context
Internal
Only
Select the node PeopleInfo in the right-hand
window and drag it across to the left-hand window.
The node must be dropped exactly on the context
root node, rather than just anywhere in the window.
Another screen will now appear in which you select
which nodes and attributes are to be mapped from
the view controller to the component controller.
Select the checkbox next to the node PeopleInfo,
and both the child attributes (FirstName and
LastName) will be selected automatically.
Press OK.
4-3 Delete the TextView UI element in which the text Welcome to Web Dynpro is displayed.
Internal
Only
Use
SAP
SAP
4-4 Add a Label UI element and an InputField UI element for each of the attributes in the
PeopleInfo context node.
Partner
Use
Only
Apply Template from the context menu.
The type of template we wish to apply is the Form
template. This is already selected by default, so
press Next.
Internal
Only
Use
defines what data will be displayed when the
screen is rendered, and also the location in which
data received from the user will be stored.
SAP
SAP
4-6 Define a new action, having the Name DataEntry and the text “Go”.
Partner
Use
Only
Finish.
Internal
Only
Use
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
interface controller.
• Share data between the context of a parent component and the interface
controller of a child component
Partner
Use
1 Development Objectives
This exercise has the following objectives:
SAP
SAP
Partner
Use
- Pass data from the component controller of the parent component to the interface
controller of the child component.
In the parent component, the context of the component controller will act as the data source.
Then the data will be shared with the view controller in parent component using internal
Internal
context mapping, and shared with the interface controller of the child component using
external mapping.
Only
Both the parent and the child components will have view controllers that display the same
data.
Internal
Only
WD Project: JA310_WD_Context_2
Application: Ex1App
Use
Starting point of this exercise:
Go on with your WD Project: JA310_Ex_1
Or start from the template solution: JA310_WD_Context_1
SAP
SAP
3 Prerequisites
You have launched the SAP NetWeaver Developer Studio.
You have selected the Web Dynpro perspective.
Partner
Use
Only
Internal
Only
Use
This is step is vital! If you do not do this, the whole exercise will fail!
We have now declared that external mapping will be used, but we have not yet defined
which node will act as the mapping origin. This step must be deferred to a later point
SAP
in time.
SAP
4-3 We now need to create a chain of context mappings from the Interface Controller,
through the Component Controller to the View Controller. The easiest way to do this
is to use the Data Modeller.
Partner
Use
Only
- Map the DataFromParent node and all child attributes.
4-5 Open the View Controller Editor for view Ex1ChildView.
- In the layout tab, change the layout property of the
RootUIElementContainer UI element from FlowLayout to
MatrixLayout.
- Change the design property of the DefaultTextView from standard to
header1.
4-6 In the Outline view, use the Apply Template functionality to define InputField UI
elements and Label UI elements which are bound to the context attributes FirstName
and LastName.
4-7 Select each of the InputField UI elements and change their readOnly property to true.
4-8 Save your metadata by clicking on the appropriate tool bar icon.
Internal
Only
Ex1Comp.
- In order to complete the external mapping relationship, expand the
childUsage component usage and then double click on the Interface
Controller node.
- Select the Properties tab of the Interface Controller.
Partner
Use
- Edit the Context Mapping of the node DataFromParent.
- Select PeopleInfo and press Next.
- Select the check box next to DataFromParent and press Finish.
SAP
A programmatic connection has now been made between the parent and child
SAP
components.
4-11 The only remaining step is to create a visual interface that will display both a view
from the parent component, and the interface view from the child component.
Partner
Use
- Double click on this window name, and the Navigation Editor will be
opened.
- Select the Create a View Set tool bar button, and click anywhere in the
Only
editor window.
This will cause a pop-up window to be displayed in which you must specify the name
and type of View Set you wish to create.
- Enter ParentViewSet as the name, and leave the ViewSetDefinition at
the default value of GridLayout.
As soon as you press finish, you will see that a 2 column, 2 row view set is created in
the navigation editor. This is not the correct definition for our view set.
- Having the view set selected, change the columns property from 2 to 1.
- Also, change the default property from false to true.
This last step is very important!
If you do not make this change, then when you run your application, you will see
nothing on the screen!
Internal
Only
4-13 Lastly, we must embed the interface view of the child component into the view set. In
this case, the interface view of the child component Ex1Child is only a single view, but
in general, it represents this entire visual interface of the component. This could be as
simple as a single view, or it could be a more complex layout involving nested view
sets. Either way, we must take whatever visual interface the child component supplies,
Partner
Use
your view set and click the mouse button.
The Embed View pop-up window will now appear.
- Select Embed Interface View of a Component Instance and press
Next.
SAP
SAP
Partner
Use
Only
Enter some values into the FirstName and LastName fields and press “Go”. The data you
enter into the top fields will be transported back to the server and the Web Dynpro
Framework will write it back to the context of Ex1View.
Use
Now, due to the chain of context mapping relationships that has been created, the data will
be available to the view controller of the child component view Ex1ChildView.
SAP
SAP
Partner
Use
Internal
Only
4 Overview: Developing
Internal
Only
Use
Use the package com.sap.training.wd.ex1.
SAP
Web Dynpro project, the Navigation Diagram
SAP
Partner
Use
The component Ex1Child will be embedded into component Ex1Comp. We will pass
data into the child component Ex1Child using external mapping. This means that a
node in the interface controller of the child component will have its isInputElement
Internal
Only
component, it must nominate one of its context nodes to act as the mapping origin for
the externally mapped node in the child component.
Internal
Only
LastName.
Partner
Use
Select the DataFromParent node and change the
isInputElement property to true. Also change its
cardinality property from 0..n to 1..1.
SAP
SAP
Partner
Use
Internal
4-3 Create a data link between the Component Controller and the Interface
Only
Controller.
Internal
Only
4-6 Use the Apply Template functionality to define InputField UI elements and Label UI
elements which are bound to the context attributes FirstName and LastName.
Partner
Use
The Form template is the default type of template,
so press Next, and select DataFromParent on the
following screen.
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
Use
SAP
SAP
4-10 Connect the externally mapped node in the Interface Controller of Ex1Child with a
context node of the component controller of parent component Ex1Comp.
Partner
Use
Controller node.
Only
Select the Properties tab of the Interface
Controller.
Press the Add button and select the Component
Controller for Ex1Comp.
Now the interface controller of the child
component usage has access to the context and
methods in the parent component controller.
Internal
Only
4-11 Create a visual interface that will display both a view from the parent component, and
the interface view from the child component.
Locate the window called Ex1Comp under the
Windows node of component Ex1Comp.
Partner
Use
this window name, and the Navigation Editor will
be opened.
Select the Create a View Set tool bar button, and
SAP
click anywhere in the editor window.
SAP
Partner
Use
Only
This is not the correct definition for our view set,
so with the view set selected (as shown on the left
side), change the columns property from 2 to 1.
Internal
Only
Press Finish and the view set should now look like
shown on the left.
Partner
Use
SAP
SAP
Partner
Use
Internal
Only
Contents:
z The Context At Runtime
z The Typed Context API
z The Generic Context API
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
z When you create context entities at design time, you are creating
the metadata that will describe the runtime data.
z Once the metadata that describes nodes and attributes has been
created, actual node collection objects can be created.
z The node collection objects for independent context nodes can
always be assumed to exist, and can therefore be accessed
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Only
Boolean property called typedAccessRequired which by default, is set to true. If this is set to
false, then the typed interface to that one node will not be generated.
For very large Web Dynpro applications, it may be necessary to switch off the generation of the typed
context API in order to reduce the volume of generated code.
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
referencing wdContext.node{cn}() where {cn} is the name of the context node. This returns
an object of type I{cn}Node.
Only
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
referencing wdContext.node{cn}() where {cn} is the name of the context node. This returns
an object of type I{cn}Node.
y Obtain a reference to the element at the node collection’s lead selection. For every node object
Only
{cn}, there is a method {cn}.current{cn}Element() that will return the relevant element
as an object of type I{cn}Element.
Internal
Only
Use
Date salesDate = soEl.getSalesDate();
String salesRep = soEl.getSalesRep();
SAP
SAP
SAP AG 2004
Partner
Use
referencing wdContext.node{cn}() where {cn} is the name of the context node. This returns
an object of type I{cn}Node.
y Obtain a reference to the element at the node collection’s lead selection. For every node object
Only
{cn}, there is a method {cn}.current{cn}Element() that will return the relevant element
as an object of type I{cn}Element.
y Once a reference to the correct element has been obtained, the relevant accessor methods can be
called to supply the attribute data. The accessor methods are always in the form get{ca}() where
{ca} is the name of the context attribute.
What assumption has been made here?
The coding above is syntactically correct, but a big assumption has been made about the contents of
node SalesOrders: It has been assumed that the node collection actually has some elements in it!
This could be a problem.
Check the cardinality of node SalesOrders again … 0..n. The zero is the give away.
When this controller is instantiated, this node will be an empty collection. Therefore to blindly use the
object returned by calling method current{cn}Element() could potentially cause a null pointer
exception.
z Typed access
z {cn} is an independent value node
Process the typed element at the lead selection of a value node
// Get a reference to node {cn}
I{cn}Node node{cn} = wdContext.node{cn}();
// Get the element at the lead selection {cn}
I{cn}Element this{cn}El = node{cn}.current{cn}Element();
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Generalised code
Generalised coding has been supplied here to show the pattern of code that should be used when
accessing data in a value node collection using the typed context API.
Accessing independent value attributes
Internal
Only
Please refer to the Appendix chapter in your notes for a full list of all the coding placeholders.
z Typed access
z {cn} is an independent value node
Process all typed elements in a value node collection
// Get a reference to node {cn}
I{cn}Node node{cn} = wdContext.node{cn}();
// Get the size of the node element collection
int size{cn} = node{cn}.size();
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Generalised code
Generalised coding has been supplied here to show the pattern of code that should be used when
accessing data in a value node collection using the typed context API.
Internal
Please refer to the Appendix chapter in your notes for a full list of all the coding placeholders.
Only
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Only
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Only
object of type I{cn}Element.
Important: The newly created node element is not yet a member of the node’s element collection!
OrderNo
SalesDate
Internal
Only
Use
newSoEl.setSalesDate(new Date(System.currentTimeMillis());
newSoEl.setSalesRep("Harry Hawk");
SAP
SAP
SAP AG 2004
Partner
Use
Only
object of type I{cn}Element.
Important: The newly created node element is not yet a member of the node’s element collection!
y Call the relevant mutator methods to populate the new element.
OrderNo 0
SalesDate
Internal
Only
Use
newSoEl.setSalesRep("Harry Hawk");
// Append the new element to the node’s collection
soNode.addElement(newSoEl);
SAP
SAP
SAP AG 2004
Partner
Use
Only
object of type I{cn}Element.
Important: The newly created node element is not yet a member of the node’s element collection!
y Call the relevant mutator methods to populate the new element.
y Once the relevant mutator methods have been called to populate the new element, it must be added
to the node’s collection using one of the {cn}.addElement() methods.
It is also possible to use one of the {cn}.bind() methods, but these methods must be used with
care because they replace the entire node collection with whatever is passed as a parameter!
Therefore, calls to the {cn}.bind() methods cannot be used in an additive manner.
z Typed access
z {cn} is an independent value node
Add a new element to a value node collection
// Get a reference to node {cn}
I{cn}Node node{cn} = wdContext.node{cn}();
// Create a new element for node {cn}
I{cn}Element new{cn}El = node{cn}.create{cn}Element();
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Generalised code
Generalised coding has been supplied here to show the pattern of code that should be used when adding
data to a value node collection using the typed context API.
Accessing independent value attributes
Internal
Only
Please refer to the Appendix chapter in your notes for a full list of all the coding placeholders.
Internal
Only
I{chn}Node node{chn}(int)
Context Element
IPrivate{nctl}.I{cn}Element String get{cn}Name()
void set{cn}Name(String)
Partner
I{chn}Element current{chn}Element()
I{chn}Element create{chn}Element()
Use
I{chn}Element get{chn}ElementAt(int)
I{chn}Node node{chn}()
SAP
SAP
SAP AG 2004
Partner
Use
The Context Node methods highlighted in grey will only be generated if node {cn} has a child node
{chn}.
The Context Element methods highlighted in grey will only be generated if {chn} is a non-singleton
node with respect to {cn}.
Internal
From within any controller, the IPrivate{nctl} interface can be used to access the context.
However, the context of a custom controller can also be accessed through the IPublic{ncc} interface.
Only
It is this feature that permits a custom controller to share the contents of its context with other
controllers!
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
attributes.
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Only
OrderNo ..n
SalesDate
OrderNo 1
SalesDate
OrderNo 0
SalesDate
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Only
requires both the name of the node and the index of the element in the parent node the desired node
instance belongs to. In this case, the parent node is the context root which only ever has one element,
therefore the index parameter is 0.
OrderNo ..n
SalesDate
OrderNo 1
SalesDate
OrderNo 0
SalesDate
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Only
requires both the name of the node and the index of the element in the parent node the desired node
instance belongs to. In this case, the parent node is the context root which only ever has one element,
therefore the index parameter is 0.
y Call getLeadSelection() to find the lead selection value. If we get -1 then no element is
currently selected.
OrderNo ..n
SalesDate
OrderNo 1
SalesDate
OrderNo 0
SalesDate
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Only
requires both the name of the node and the index of the element in the parent node the desired node
instance belongs to. In this case, the parent node is the context root which only ever has one element,
therefore the index parameter is 0.
y Call getLeadSelection() to find the lead selection value. If we get -1 then no element is
currently selected.
y Calling method getElementAt() with a parameter of -1 will result in a runtime error – the if
statement prevents this. Now get the element at the node collection’s lead selection. This returns a
generic IWDNodeElement object.
OrderNo ..n
SalesDate
OrderNo 1
SalesDate
OrderNo 0
SalesDate
Internal
Only
Use
// Get the attribute values using the generic accessor methods
String longText = soEl.getAttributeAsText("LongText");
int orderNo = ((Integer)soEl.getAttributeValue("OrderNo")).intValue();
Date salesDate = (Date)soEl.getAttributeValue("SalesDate");
String salesRep = soEl.getAttributeAsText("SalesRep");
SAP
SAP
SAP AG 2004
Partner
Use
Only
requires both the name of the node and the index of the element in the parent node the desired node
instance belongs to. In this case, the parent node is the context root which only ever has one element,
therefore the index parameter is 0.
y Call getLeadSelection() to find the lead selection value. If we get -1 then no element is
currently selected.
y Calling method getElementAt() with a parameter of -1 will result in a runtime error – the if
statement prevents this. Now get the element at the node collection’s lead selection. This returns a
generic IWDNodeElement object.
y Since we are using the generic interface, the IWDNodeElement object has no typed accessor or
mutator methods for any of the attributes. Therefore, we must use either
getAttributeAsText() or getAttributeValue(). In the case of method
getAttributeValue(), you must know what data type the attribute has, and cast the resulting
Object appropriately.
z Generic access
z {cn} is an independent value node
Process the generic element at the lead selection of a value node
// Get a generic reference to node {cn}
IWDNode node{cn} = wdContext.getChildNode("{cn}",0);
int leadSel = node{cn}.getLeadSelection();
// Select element 0 if no element is currently selected
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Generalised code
Generalised coding has been supplied here to show the pattern of code that should be used when
accessing data in a value node collection through the generic context API.
Internal
Please refer to the Appendix chapter in your notes for a full list of all the coding placeholders.
Only
Context Root
SalesOrders Default 0
Element
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
passed both the name of the required context node, and the index of the element in the parent node
collection to which the required node belongs.
Only
Context Root
SalesOrders Default 0
Element
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
passed both the name of the required context node, and the index of the element in the parent node
collection to which the required node belongs.
y Create a new generic node element using method {cn}.createElement(). This returns a
Only
generic context element of type IWDNodeElement.
Context Root
SalesOrders Default 0
Element
OrderNo
SalesDate
Internal
Only
Use
newSoEl.setAttributeValue("SalesRep","Harry Hawk");
SAP
SAP
SAP AG 2004
Partner
Use
passed both the name of the required context node, and the index of the element in the parent node
collection to which the required node belongs.
y Create a new generic node element using method {cn}.createElement(). This returns a
Only
generic context element of type IWDNodeElement.
y Call the generic mutator methods to set the attribute values. The setAttributeValue() method
requires the name of the attribute and the value to be assigned. You can specify the attribute value as
either a String or an Object.
Context Root
SalesOrders Default 0
Element
OrderNo 0
SalesDate
Internal
Only
Use
newSoEl.setAttributeValue("SalesRep","Harry Hawk");
// Append the new element to the node’s collection
soNode.addElement(newSoEl);
SAP
SAP
SAP AG 2004
Partner
Use
passed both the name of the required context node, and the index of the element in the parent node
collection to which the required node belongs.
y Create a new generic node element using method {cn}.createElement(). This returns a
Only
generic context element of type IWDNodeElement.
y Call the generic mutator methods to set the attribute values. The setAttributeValue() method
requires the name of the attribute and the value to be assigned. You can specify the attribute value as
either a String or an Object.
y Finally, the new element, it must be added to the node’s collection using one of the
{cn}.addElement() methods.
z Generic access
z {cn} is an independent value node
Add a new generic element to a value node collection
// Get a generic reference to node {cn}
IWDNode node{cn} = wdContext.getChildNode("{cn}",0);
// Create a new element for node {cn}
IWDNodeElement new{cn}El = node{cn}.createElement();
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Generalised code
Generalised coding has been supplied here to show the pattern of code that should be used when adding
data to a value node collection using the generic context API.
Internal
Please refer to the Appendix chapter in your notes for a full list of all the coding placeholders.
Only
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Partner
1 Development Objectives
This exercise has the following objectives:
Use
- Define a context value node in the component controller.
- Map the value node to the view controller
- Write the required coding in the component controller to add some data to the value node.
- Display the contents of the mapped value node in the view controller on the screen
SAP
SAP
The context of the component controller will act as the data source. Then using context
mapping, the data will be shared with a view controller. Once the data is available to the
context of the view controller, UI elements can be added to the view layout. These UI
Partner
elements will then be bound to the context of the view controller.
Use
The data that will be displayed on the screen will be created at runtime by the coding you
will add
Internal
2 Result
Only
In this exercise, you will create a context
node in the component controller. Then
you will create a corresponding node in
the view controller that is mapped to the
context node in the component controller.
The View layout will contain fields
shown on the left.
The data will be created by runtime
coding that you will add.
3 Prerequisites
You have launched the SAP NetWeaver Developer Studio.
You have selected the Web Dynpro perspective.
The structure of the project that you will create is shown in the screen shot below.
Internal
Only
Partner
Use
SAP
SAP
Partner
Use
Internal
Only
4 Overview: Developing
4-1 Create a new Web Dynpro project called JA310_Ex_4. Without changing any other
values, press Finish.
4-2 Create a new Web Dynpro Component having the following properties:
Name: Ex4Comp
Package: com.sap.training.wd.ex4
Window Name: Ex4Comp
View Name: Ex4View
Press Finish.
4-3 Open the Custom Controller editor by double clicking on the Component Controller of
the component Ex4Comp.
The data type of an attribute can be changed from the properties view of this context
attribute.
4-5 Open the Diagram view of the Data modeller for component Ex4Comp by double
clicking on the corresponding node in the Web Dynpro Explorer.
Internal
Only
- Create a data link between the view controller and the component
controller.
This will open a pop-up window called Edit Context Mapping.
- Select the node SalesOrders in the right-hand window and drag it
across to the left-hand window.
Partner
The node must be dropped exactly on the context root node, rather than just anywhere
in the window!
Use
Another screen will now appear in which you select which nodes and attributes are to
be mapped from the view controller to the component controller.
- Select the checkbox next to the node SalesOrders, and all the child
attributes will be selected automatically.
SAP
- Press OK.
SAP
- Press Finish.
4-6 Change the properties of the UI elements defined in view Ex4View.
- Double click on the view Ex4View in the Web Dynpro Explorer to edit
Partner
Use
the view.
- Select the RootUIElementContainer in the Outline view and change its
layout property to MatrixLayout.
- Select the DefaultTextView in the Outline view and changes its design
Internal
property to header1.
4-7 Add a Label UI element and an InputField UI element for each of the attributes in the
Only
SalesOrders context node.
- Use the Apply Template functionality, which can be found in the
context menu of the RootUIElementContainer element.
- Select the Form template.
- On the next screen, check the node SalesOrders and all the child
attributes.
- Press Finish.
The Apply Template wizard has now done several things for us. It has added a Label
and an InputField for each attribute in the node SalesOrder, and it has bound the value
property of each InputField to the appropriate context attribute.
This is the critical configuration step that both defines what data will be displayed
when the screen is rendered, and also the location in which data received from the
user will be stored.
Internal
Only
Use
5 Overview: Building, Deploying, and Running
Right mouse click on the newly created application and select Deploy New Archive and Run.
SAP
SAP
Partner
Use
Internal
Only
Notice that a date picker icon appears next to the date field. This is created automatically!
All you need to do is bind an InputField UI element to a context attribute of type date, and
the Web Dynpro Framework will generate the correct interface.
4 Overview: Developing
Internal
Only
4-2 Create a new Web Dynpro Component having the name Ex4Comp.
Use
In the next pop-up screen, give the new
component the following values:
Name: Ex4Comp
Package: com.sap.training.wd.ex4
SAP
SAP
Partner
Use
Only
Internal
Only
Partner
4-4 Create a new Web Dynpro Component having the name Ex4Comp.
Use
By default, the Context tab will be displayed when
the Custom Controller editor is first opened. The
context of the component controller is currently
empty; therefore, right mouse click on the word
SAP
SAP
Partner
Use
Only
properties tab in the lower right-hand window. Now
locate the type property and select an appropriate
data type from the drop down list.
Internal
Only
We have just defined a value node in the context of the component controller. We now
Partner
need to share this runtime information with the view controller. Select the arrow icon
from the toolbar on the upper left side of the editor window (Create a data link).
Starting from the view controller, drag a line into component controller and release the
Use
mouse button. This will open a pop-up window called Edit Context Mapping.
The Edit Context Mapping window is divided into two, vertical halves. On the right
SAP
side is the context of the component controller (where you can see the node
SAP
SalesOrders) and on the left is the context of the view controller (which is currently
empty).
Select the node SalesOrders in the right-hand window and drag it across to the left-
Partner
hand window. The node must be dropped exactly on the context root node, rather than
Use
Only
Select the checkbox next to the node SalesOrders,
and all the child attributes will be selected
automatically.
Press OK.
Once the context mapping is complete and the tree
structures expanded, you will see the display
shown on the left.
Press Finish.
Internal
Only
Use
and ensure that all the child attributes are selected.
Since we can accept the default values that will
appear on the next screen, you can simply press
Finish now.
SAP
SAP
Partner
Use
Internal
4-8 Return to the Component controller editor and select the implementation tab…
In the bottom left of the NetWeaver Developer Studio screen you will now see that the
Only
Outline View shows the classes and methods within the selected program.
Select the method wdDoInit() in the Outline View and you will see the editor
window jump to the appropriate location in the code.
The following code needs to be added to the wdDoInit() method of the component
controller for Ex4Comp.
Internal
Only
newSoEl.setDescription("Printer supplies");
newSoEl.setOrderNo(1000);
newSoEl.setSalesDate(new Date(System.currentTimeMillis()));
newSoEl.setSalesRep("Harry Hawk");
Partner
Use
..//@@end
Important: You should only add coding between the //@@begin and //@@end
comment markers!
SAP
SAP
Partner
Use
Internal
Only
Contents:
z Introduction to UI elements
z Putting data on the screen: Context binding
z Controlling the behaviour of UI elements using context
binding
z Using a basic composite UI element
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
InputField UI Element
TextView UI Element
Internal
Only
Label UI Element
Partner
Use
SAP AG 2004
SAP
SAP
Partner
No! There are certain UI elements that are not visible on the screen, such as the
Use
No, not necessarily! Web Dynpro has been designed to operate with any form-based user interface. This
is most probably going to be a standard browser, but it could also be a Pocket PC™ or a Blackberry™.
Only
Internal
Only
Use
SAP AG 2004
SAP
SAP
All subsequent UI elements added to a view layout are hierarchically subordinate to the UI element
Partner
called RootUIElementContainer.
Use
Internal
Only
BarCodeReader,
FunctionKey, RFIDReader
InteractiveForm
e.g. DateNavigator, Table, Tree
Internal
Only
OfficeControl
BusinessGraphics, GeoMap
Partner
Use
independent of any client presentation layer.
SAP AG 2004
SAP
SAP
There are numerous user interface elements available for designing the user interface of a Web Dynpro
Partner
application.
Use
All available user interface elements are divided into categories and can be selected using buttons in the
view designer.
Simple Standard elements are:
Button, Caption, CheckBox, CheckBoxGroup, DropDownByIndex, DropDownByKey, FileDownload,
Internal
Only
ToolbarDropDownByKey, ToolBarInputField, ViewContainerUIElement
Complex Standard elements are:
DateNavigator, PhaseIndicator, RoadMap, TabStrip, Table, Tree
Container Standard Elements are:
Group, ScrollContainer, TransparentContainer, Tray
Internal
Only
Partner
Use
1. Choose Edit from the
context menu of a view
SAP AG 2004
SAP
SAP
View Designer
Partner
The View Designer is a Web Dynpro specific tool that allows you to edit a view layout. The View
Use
Designer is only available when you are editing a view controller. It will not appear when you edit a
custom controller because these controllers have no visual interface.
Using the View Designer
y To open the View Designer, select a view and then choose Edit from the right mouse click menu.
Internal
This can be done from the Web Dynpro Explorer, the Navigation Modeler, or Data Modeler.
Only
Internal
Only
Partner
Use
1. Choose Edit from the
context menu of a view
SAP AG 2004
SAP
SAP
View Designer
Partner
The View Designer is a Web Dynpro specific tool that allows you to edit a view layout. The View
Use
Designer is only available when you are editing a view controller. It will not appear when you edit a
custom controller because these controllers have no visual interface.
Using the View Designer
y To open the View Designer, select a view and then choose Edit from the right mouse click menu.
Internal
This can be done from the Web Dynpro Explorer, the Navigation Modeler, or Data Modeler.
y Now select the Layout tab.
y If you want to enlarge the work area in which you position the individual interface elements, double-
Only
click the header bar in the editor. To revert to the original size, double-click the same bar again.
Internal
Only
Partner
Use
1. Choose Edit from the
context menu of a view
SAP AG 2004
SAP
SAP
Partner
To add any UI element, drag and drop it from the toolbar on the left hand side of the View Designer.
Use
Internal
Only
Internal
Only
Partner
Use
1. Choose Edit from the
context menu of a view
SAP AG 2004
SAP
SAP
Partner
To add any UI element, drag and drop it from the toolbar on the left hand side of the View Designer.
Use
Adding a new UI element from the Outline View is also possible. This can be done from the context
menu of an element in the hierarchy, that can have child elements (e.g. a Transparent Container
element, a Group element).
Positioning of the UI elements is done by changing the element hierarchy.
Internal
Only
Internal
Only
Partner
Use
1. Choose Edit from the
context menu of a view tab selected during editing.
SAP AG 2004
SAP
SAP
UI elements properties
Partner
The Properties tab displays all properties of a given UI element.
Use
Supported client-side events can be found as child's of the properties node Event. To handle these
client-side events, previously defined Actions have to be associated with each of the events. The
allowed Actions can be chosen from a drop down list.
Internal
Only
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Context
Root Node
Internal
Only
por t
dat a tr ans
at ic
Aut om
Partner
Use
SAP AG 2004
SAP
SAP
Once a UI element property is bound to a context node or attribute, the context data is used to supply a
Partner
value to the UI element property. If the UI element property is one that the user can update (e.g. the
Use
value property of an InputField UI element), then the context is automatically updated with new
value during the next round trip.
Almost all the properties of a UI element can be bound either to a context node or attribute.
A binding relationship can only exist between the context and UI elements of the same view controller.
Internal
Only
Application Coding
Implementation UI Layout
Standard Context
Hook
Root Node
Methods
Internal
Only
por t
Instance
dat a tr ans
Methods at ic
Aut om
Actions
Partner
Navigation
Use
Plugs
SAP AG 2004
SAP
SAP
A Web Dynpro view controller has been constructed in such a way that it is normally possible to have
Partner
full control over the appearance of the screen layout, without ever needing direct access the UI element
Use
objects.
Any property over which you wish to have programmatic control should be bound to an appropriate
context node or attribute.
Internal
Only
Implementation UI Layout
Standard Context
Hook
Root Node
Methods
Internal
Only
por t
Instance t a tr ans
Updates
da
Methods at ic
Aut om
Actions
Partner
Navigation
Use
Plugs
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
1) Declare context
attribute
Partner
Use
SAP AG 2004
SAP
SAP
Partner
In order for a UI element to display any data, at the very least, its value property must be bound to an
Use
appropriate context node or attribute (there are very few UI elements that do not have a value property
– HorizontalGutter for instance).
The following steps are the minimum requirement for putting some data on the screen:
Internal
y Create a node or attribute in the view controller‘s context that will contain the data. It is not
important whether this a mapped context node or not.
Only
2) Create UI element
on layout
Internal
Only
1) Declare context
attribute
Partner
Use
SAP AG 2004
SAP
SAP
Partner
In order for a UI element to display any data, at the very least, its value property must be bound to an
Use
appropriate context node or attribute (there are very few UI elements that do not have a value property
– HorizontalGutter for instance).
The following steps are the minimum requirement for putting some data on the screen:
Internal
y Create a node or attribute in the view controller‘s context that will contain the data. It is not
important whether this a mapped context node or not.
y Create the UI element on your view layout.
Only
Internal
Only
1) Declare context
attribute
Partner
Use
SAP AG 2004
SAP
SAP
Partner
In order for a UI element to display any data, at the very least, its value property must be bound to an
Use
appropriate context node or attribute (there are very few UI elements that do not have a value property
– HorizontalGutter for instance).
The following steps are the minimum requirement for putting some data on the screen:
Internal
y Create a node or attribute in the view controller‘s context that will contain the data. It is not
important whether this a mapped context node or not.
y Create the UI element on your view layout.
Only
y Display the UI element’s properties by clicking on the UI element itself in the view layout, and then
select the Properties view.
Here, you will see a red X icon against any UI element property that requires a context binding.
Place the cursor in this field and an ellipsis button will appear at the right hand side. Click here and a
pop-up window will be displayed showing the view controller’s context.
Select an appropriate node or attribute and then this value will be transferred back to the Properties
view. The red X icon will now be a replaced with a green tick icon, and the context path will be
displayed in the field.
The UI element on the view layout will now also display the context path of the node or attribute to
which it is bound.
Internal
Only
1) Declare context
attribute
Partner
Use
SAP AG 2004
SAP
SAP
Partner
The establishment of a binding relationship instructs the Web Dynpro screen renderer to obtain the
Use
value for UI element property from the context node or attribute to which it is bound.
Context binding is not limited to simply supplying and InputField, say, with a value. A UI
element’s value property is just one of the many properties that can be supplied with data through a
Internal
binding relationship.
Only
This is the mechanism by which a view controller can adjust the appearance and behaviour of its view
layout without ever needing to access the UI element objects themselves.
Internal
Only
relationship:
Data from the context is transported to the client during screen rendering
Data entered by the user is transported back to the context when the HTTP
Use
round-trip is processed.
SAP AG 2004
SAP
SAP
Partner
As can be seen from the graphic above, there is no requirement to have the UI elements in the same
Use
initiated an HTTP round-trip, the new or modified data in the UI elements is transported back to the
same nodes and attributes in the view controller’s context. By the time the Web Dynpro Framework
hands controller over to your action handler, the context already holds the updated information.
Only
This two-way transport process is entirely automatic, and requires no action on the part of the
application developer. All you need to do is declare that a binding relationship exists.
2.The corresponding
input field will always
be open for input.
Internal
Only
Use
good UI design and should be avoided!
SAP AG 2004
SAP
SAP
UI Element properties
Partner
The value of a UI element property can either be hard coded, or it can be bound to a context attribute of
Use
a suitable data type. The graphic above illustrates this principle for the readOnly property, but can be
applied to almost all properties of a UI element.
Changing hard coded UI element property values
If you need to change the value of a UI element property value that has been hard coded at design time,
Internal
this can be done at runtime by placing coding in the view controller’s wdDoModifyView() method.
But this type of architecture is considered a poor design and should be avoided!
Only
Internal
Only
Partner
Use
property can be controlled by
an attribute of type boolean
SAP AG 2004
SAP
SAP
Partner
In order to programmatically control the behaviour of a UI element, you should create a context attribute
Use
that is of the same data type as the property you wish to control. Your wdDoInit() or action handler
methods can then modify the value of the context attribute and control the behaviour of the UI element,
without ever needing to access the UI element object itself.
Internal
Only
Internal
Only
Use
SAP AG 2004
SAP
SAP
Partner
Once the context attribute has been created, it must be bound to the appropriate property of the UI
Use
element. In this case, the readOnly property of an InputField UI element has been bound to a
boolean value attribute.
Now the wdDoInit() method, or one of your action handlers, can manipulate the context attribute.
Internal
This techniques gives you programmatic control over any bindable UI element property, and allows you
to control the appearance of the view layout without any need to access the UI element objects
Only
themselves.
Internal
Only
Use
SAP AG 2004
SAP
SAP
Partner
Certain UI element properties have been abstracted in order to make them independent from the client
Use
software layer. This means that certain familiar HTML parameters such as heading levels cannot be
specified in the customary manner.
In these cases, specific classes have been created in the Web Dynpro dictionary to describe these data
Internal
types. When creating a context attribute to control, for instance, the design property of a TextView
UI element, you must declare the context element to be of type
Only
com.sap.ide.webdynpro.uielementdefinitions.TextViewDesign.
These classes can be found by clicking on the ellipsis button next to a context attribute’s data type, and
then selecting Local Dictionary as shown in the graphic above.
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
Partner
Use
UI element
SAP AG 2004
SAP
SAP
Composite UI elements
Partner
y Certain UI elements are displayed on the screen as aggregations of simpler, more basic, UI elements.
Use
Only
structure.
Internal
Only
composite UI elements.
Partner
Use
SAP AG 2004
SAP
SAP
Composite UI elements
Partner
Certain UI elements are displayed on the screen as aggregations of simpler, more basic, UI elements.
Use
Notice in the graphic, that the Table UI element acts as a parent for several TableColumn UI
elements; each of which acts as the parent for a Caption and TextView UI element.
Internal
Without the subordinate, or child UI elements, a composite UI element is not capable of displaying any
Only
information.
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
Notice that the name of any UI element is described in three parts.
Use
For example:
Only
<UI Element Name> [<UI Element Type> – <Role>]
So SalesOrdersTable is a UI element of type Table and fulfils the role of Child with respect to
its parent UI element.
OrderNo is a UI element of type TableColumn and fulfils the role of Column with respect to its
parent UI element.
Description
ItemNo
Internal
Only
Price
Quantity
Use
Design Time Runtime
SAP AG 2004
SAP
SAP
Table UI Element
Partner
The Table UI element allows the two-dimensional display of data in cells arranged in rows and
Use
columns. The UI element consists of an optional header area, zero or more rows, and footer area. The
element at the lead selection in the context node becomes the highlighted row when displayed on the
screen.
Internal
Only
The caption appearing at the top of the table (in this case Sales Orders) is optional.
Description
Each context attribute is a
ItemNo
potential candidate for
becoming a TableColumn.
Internal
Only
Price
Quantity
OrderNo
SalesDate
Partner
View layout
SalesRep
LongText
Use
Design Time Runtime
SAP AG 2004
SAP
SAP
TableColumn UI Elements
Partner
TableColumn UI elements must be bound to the attributes of the node to which the parent Table UI
Use
element is bound. Any node attribute of a simple data type is a candidate for becoming a table column.
TableColumn UI elements are composite UI elements! This means that they must have child UI
Internal
Only
Internal
Only
Price
Quantity
Mandatory table cell
OrderNo editor UI element
SalesDate
Partner
Use
Design Time Runtime
SAP AG 2004
SAP
SAP
Partner
In order to present information to the user, a TableColumn UI element must have a child UI element
Use
that will act as the cell editor. In order to decide which UI element to use, ask yourself this question:
The answer to this question then determines how this user interacts with the data in that one column.
Only
Don’t think that because the name of this role contains the word editor that the user can necessarily
change the data. If you select some sort of display only UI element such as a TextView, then the user
will not be able to modify the data – the UI element you chose does not permit it!
If on the other hand, you chose an InputField to be the table cell editor, then all the cells appearing
in that column would, by default, be open for input.
The caption appearing as the column header is optional, but if defined, will always be of type
Caption.
Context Root
z Each element in the node
Context Metadata Default 0 collection becomes a table
Element row
Context Root
SalesOrders (c=0..n)
LineItems (c=0..n)
SalesOrders
Description OrderNo 1
ItemNo SalesDate
OrderNo 0
SalesDate
Internal
Only
Price
Quantity
Runtime data View layout
OrderNo
SalesDate
Partner
Use
Design Time Runtime
SAP AG 2004
SAP
SAP
Partner
Any time you click on a table row on the rendered screen, an HTTP round trip is initiated. This round
Use
trip will cause the lead selection of the corresponding context node to which this table is bound to be
adjusted.
In the graphic above, the node collection contains two elements, and the user has clicked on the second
Internal
table row. This corresponds to element 1 of node SalesOrders, and the lead selection of this node is
altered to reflect the user’s selection.
Only
There will be as many rows in the table as there are elements in the node collection.
You can also define a Web Dynpro Action and associate it with the Table’s onLeadSelect event.
Now, not only will the node collection’s lead selection element be adjusted when the user clicks on a
table, but your action handler will also be invoked.
Context Root
SalesOrders (c=0..n)
LineItems (c=0..n)
Description
ItemNo
Internal
Only
Price
Quantity
View layout
OrderNo
Use
Design Time Runtime
SAP AG 2004
SAP
SAP
Partner
Before a user is permitted to select multiple rows from a table (by holding down shift, and clicking on
Use
the required rows), the context node to which the Table UI element is bound must have a selection
cardinality of either 0..n or 1..n. The default selection cardinality setting for any context node is
0..1, meaning that zero or one elements may be selected at any one time.
Internal
Only
elements in the collection, testing the isMultiSelected flag as follows:
Warning: If the selection cardinality has been set to 0..1 or 1..1, the flag isMultiSelected is
not set for any of the elements. To find out, which element of a collection has been selected, the method
getLeadSelection() of the node collection has to be used.
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Chapter: UI Elements
Theme: Standard and Container UI Elements
Internal
Only
1 Development Objectives
Partner
Container UI Elements
Use
Container UI Elements can be used to group a set of UI elements in the layout of a view.
The following container UI elements exist: Group, Scroll Container, Transparent
Container, and Tray.
For each container UI element layout properties can be used to define the alignment of the
SAP
SAP
Partner
Use
2 Result
Only
Tray UI element).
Optional: You will set image properties
programmatically.
Optional Part:
Template Solution:
WD Project: JA310_WD_UIElements_1opt
Application: JA310_WD_UIElements_1opt
Internal
Only
Starting point:
Go on with your WD Project: JA310_WD_UIElements_1T
Or start from the template solution: JA310_WD_UIElements_1.
Partner
3 Prerequisites
Use
You have launched the SAP NetWeaver Developer Studio.
You have selected the Web Dynpro perspective.
You have opened the JA310_WD_UIElements_1T project.
SAP
The structure this project is currently displayed in the Web Dynpro Explorer.
SAP
Partner
Use
Only
4-1 Add a Tray UI element to the view Ex5View. Define the Trays title.
4-2 Add a TextView to the Tray UI element and define the text property of this element
(an arbitrary text shall be displayed).
4-3 Add a Group UI element to the Tray UI element. Define the Groups title. Position
the Group element below the TextView element.
4-4 Add an Image to the Group UI element. Name of the image: explosion.gif. This
image has already been imported into the project. In addition, set the value of the
properties alt and tooltip.
4-5 Create the Web Dynpro application JA310_WD_UIElements_1.
Internal
Only
Use
6 Optional: Setting image properties programmatically
6-1 Bind the image properties alt and source to the context of the view container:
SAP
SAP
- Add a new value node to the view controller context, having the
name Image. Change the cardinality of this node to 1..1.
- Add two new value attributes to the value node Image, having the
names ImgSource and ImgAlt.
Partner
Use
- Edit the properties of the context value attributes. Set the property
calculated to true. This will result in the automatic generation of
getter methods for these context value attributes.
- Bind the properties alt and source of the Image UI element to these
Internal
context elements.
6-2 Set the image properties source and alt programmatically:
Edit the getter methods for the two context value attributes.
Only
Chapter: UI Elements
Theme: Container UI Elements
4 Developing, Step-by-Step
Internal
Only
Select the node Ex5View and choose Edit from the context menu.
Use
The View Designer for the view Ex5View appears
on the right pane
SAP
In the toolbar, choose Container Standard. Drag
SAP
Partner
Use
Save the new project data by choosing Save All Metadata from the toolbar.
Only
Internal
Only
Partner
Save the new project data by choosing Save All Metadata from the toolbar.
Use
4-3 Add a Group to the Tray UI element.
SAP
SAP
In the Outline view, select the Tray element and choose Insert Child from the context
menu.
Or:
Partner
Use
From the toolbar, choose Container Standard and drag and drop Group to the editor
pane.
Internal
Only
text Group title
Save the new project data by choosing Save All Metadata from the toolbar.
Internal
Only
alt explosion.gif
Source explosion.gif
Tooltip Boom!
Partner
The simplest way to insert a picture is by assigning its file name - in this example,
Use
explosion.gif - as a value to the source property of the Image UI element. The picture
file must be stored in the directory
<ProjectFolder>/src/mimes/Components/<ComponentPackageName
SAP
>.
SAP
This directory was automatically created when adding the Web Dynpro component
Ex5Comp.
(Optional: Take a look at Step 6. There you will find, how
Partner
Use
Save the new project data by choosing Save All Metadata from the toolbar.
Internal
Only
Successful Result
Internal
Only
Select
Partner
Use
Startup Plug Default
and choose Finish.
SAP
SAP
Successful result:
The generated Web Dynpro application object completes your project structure. You can
now deploy your project and start your Web Dynpro application.
Partner
JA310_WD_UIElements_1 enables you to address the Web application as a whole, when
Use
Only
To deploy and run the application, choose Deploy new Archive and Run
Successful result:
Internal
Only
Use
SAP
SAP
Partner
Use
Internal
Only
6-1 Bind the image properties alt and source to the context of the view.
Internal
Only
calculated true
Use
This will automatically result in the generation of a
getter- and a setter-method for the context value
attributes ImgSource and ImgAlt, respectively.
SAP
SAP
Partner
Use
source Image.ImgSource
Only
This will bind the image properties to the view
context.
Save the new project data by choosing Save All Metadata from the toolbar.
In the View Designer, choose the tab Implementation, select the generated methods
getImageImgSource and getImageImgAlt. Add the following return statement:
. . .
Internal
Only
return "explosion.gif";
//@@end
}
Partner
. . .
Use
public java.lang.String getImageImgAlt(
IPrivateImageView.IContextElement element)
{
//@@begin getImageImgAlt( . . .
SAP
SAP
Partner
Use
Save the new project data by choosing Save All Metadata from the toolbar.
Only
Chapter: UI Elements
Theme: Dictionary, Table
Internal
Only
1 Development Objectives
Defining Dictionary Structures
Partner
In the Web Dynpro perspective, you can comfortably create simple data types and
structures, immediately deploy them to the SAP Web Application Server, and then use
them in your Web Dynpro application straight away without having to switch to the Java
Use
Dictionary even once.
Structures created in the Java Dictionary can be reused in different Web Dynpro contexts.
SAP
SAP
Tables
Table UI elements allows authors to arrange data, preformatted text, and so on into rows
Partner
and columns of cells.
Use
Internal
2 Result
Only
In this exercise, you will define a table
and insert some data into it.
Optional part I:
You will learn, how to display details of a
selected row.
Optional part II:
You will learn, how to delete an entry of
a table.
Optional part III:
You will learn, how to sort the table
content.
Optional Part I:
Template Solution:
WD Project: JA310_WD_UIElements_2opt1
Application: JA310_WD_UIElements_2opt1
Starting point:
Internal
Only
Template Solution:
WD Project: JA310_WD_UIElements_2opt2
Use
Application: JA310_WD_UIElements_2opt2
Starting point:
Go on with your WD Project: JA310_WD_UIElements_2T
SAP
Or start from the template solution: JA310_WD_UIElements_2opt1.
SAP
Partner
Use
WD Project: JA310_WD_UIElements_2opt3
Application: JA310_WD_UIElements_2opt3
Starting point:
Go on with your WD Project: JA310_WD_UIElements_2T
Internal
Only
Internal
Only
TableView.
Use
TableView
Here you have to insert a table
displaying person information.
SAP
TableDetailView
SAP
Partner
Use
4 Overview: Developing
Internal
4-1 Define the data transport from the StartView to the Component Controller.
Only
4-1-1 Define a Dictionary structure type, having the Name Person and the
components FIRSTNAME, LASTNAME (both of type string, not null),
DATEBEGIN and DATEEND (both of type date).
4-1-2 Define a new value node for the context of the view StartView having the
name Person with structure binding to the structure Person you have
defined in the step before.
In the Properties View, set the cardinality of this node to 1..1.
4-1-3 For the view StartView, bind the input field UI elements to the value
attributes of the context node Person.
4-1-4 Create a new value node in the context of the component controller with
structure binding to the structure Person. Name this value node People.
Internal
Only
PeopleElement.
- Don't forget to add the local instance of the PeopleElement to the
context node People.
Partner
4-2 In the Layout of view TableView, define a table UI element. Bind this UI element
to the views context.
Use
4-2-1 Define the context mapping between the component controller and the view
TableView. Define the mapping between the value node People of the
component controller and the context of the view.
4-2-2 Define the table UI element. Position the table UI element between the
SAP
SAP
default TextView element and the Group UI element containing the Button.
4-2-3 Define the table binding between the table UI element and the context:
The elements FIRSTNAME and LASTNAME of the value node People shall
be bound to columns of the table UI element.
Partner
Use
Only
Internal
Only
Partner
6-1-1 Define the data transport from the view TableView to the view
TableDetailView.
Use
- Define the context mapping between the context of the view
TableDetailView and the component controller context. Create the
context node People in the TableDetailView by mapping the component
controllers context node People to the views context.
SAP
SAP
6-1-2 Add input fields for all context elements to the detail view
TableDetailView. Apply the template Form to define input fields and
labels.
Partner
Use
6-1-3 Define the navigation between the views TableView and TableDetailView.
6-1-4 Build, deploy and run the application.
Internal
Only
Internal
Only
6-2-1 Define a toolbar for the table in the view TableView. Add a toolbarButton
to the toolbar, having the text Delete Entry.
6-2-2 Define an action (DeleteEntry) for the toolbar button und bind the
toolbarButton to this action.
Partner
6-2-3 Implement the event handler bound to the action DeleteEntry in order to
delete a person’s entry:
The Method wdContext.nodePeople().getLeadSelection() can be used to
Use
find out the index of the selected element.
The Method wdContext.nodePeople().getElementAt(index) can be used to
get back the reference to the element with index index.
SAP
SAP
Partner
Use
Internal
Only
6-3-1 Update the structure Person in the local dictionary. Add an additional
attribute DURATION (type long).
6-3-2 Update the context of the component controller and the mapping between
Internal
Only
Use
6-3-3 Calculate the DURATION as the difference between the DATE_BEGIN
and DATE_END.
- In the component controller context, set the calculated property of the
attribute DURATION to true.
SAP
SAP
Partner
Use
Only
Chapter: UI Elements
Theme: Dictionary, Table
4 Developing, Step-by-Step
Note: In this exercise you have to type in some lines of java code. For your convenience,
you can cut and paste the code from the corresponding solution project.
Internal
Only
But keep in mind: Some of the methods are automatically generated by Web Dynpro
.Because of that, the methods names you have to choose can differ from the method
names of the solution.
4-1 Define the data transport from the StartView to the component controller.
Partner
Use
In the Web Dynpro Explorer:
SAP
SAP
Partner
Use
Only
In the wizard that appears, enter
Structure Person
name
Structure com.sap.training.
package ja310.wd_uielements_2t
Choose Finish.
© SAP AG JA310 6-54
Define the elements of the structure:
Assign the following property values:
Element Name Built-in Not null
Type
FIRSTNAME string x
LASTNAME string x
DATE_BEGIN date
DATE_END date
Save the new project data by choosing Save All Metadata from the toolbar.
Internal
Only
4-1-2 Define a new value node for the context of the view StartView having the name
Person with structure binding to the structure Person.
Partner
Use
Expand the nodes JA310_WD_UIElements_2T / Web Dynpro / Web Dynpro
Components / Ex6Comp / Views.
Select the view StartView and open the context menu. Choose Edit.
SAP
SAP
Partner
Use
Only
Internal
Only
Partner
Use
In the Properties View assign the value 1..1 to the
property cardinality of the value node Person.
SAP
SAP
Partner
Use
Internal
Save the new project data by choosing Save All Metadata from the toolbar. Only
Internal
Only
Use
Assign the names of the context value attributes to
the value property of the corresponding UI
elements.
SAP
SAP
Partner
Use
Save the new project data by choosing Save All Metadata from the toolbar.
Internal
Only
Internal
Only
Use
defined before.
SAP
context attributes FIRSTNAME, LASTNAME,
SAP
Partner
Use
Internal
Only
Save the new project data by choosing Save All Metadata from the toolbar.
Internal
Only
Use
SAP
SAP
Partner
Use
Only
Internal
Only
Note: Some of the following methods were generated by Web Dynpro after you’ve
specified the context value nodes and values. Because of that, the methods names
you have to choose can differ from the following names:
Partner
Use
// Create a new People element
IPeopleElement newPerson =
wdContext.nodePeople().createPeopleElement();
SAP
SAP
Partner
Use
Only
wdThis.wdFirePlugToTableView();
//@@end
}
This method is called, after the user has pressed the button Show names.
The Web Dynpro automatically stores the values of the input fields in the component
context. The data entered in the view StartView is added to the element collection of
the node People.
In the next steps, the columns of a TableView UI element are bound to this context
node, the element collection is displayed – each element making up a single line.
Save the new project data by choosing Save All Metadata from the toolbar.
4-2-1 Define the context mapping between the component controller and the view
TableView..
Internal
Only
Use
The dialog box for defining the context mapping
appears.
SAP
SAP
Partner
Use
Press Finish.
Select the node People. This will also select all Only
child attributes.
Press OK.
Press Finish.
Save the new project data by choosing Save All Metadata from the toolbar.
Internal
Only
Use
Expand the nodes JA310_WD_UIElements_2T / Web Dynpro /
Web Dynpro Components / Ex6Comp.
SAP
SAP
Partner
Use
Only
and drop Table to the editor pane on the right.
Select the Views node and open the context menu of TableView.
Choose Edit.
Internal
Only
Use
In the wizard that appears, select FIRSTNAME
and LASTNAME from the node People.
SAP
SAP
Choose Finish.
Partner
Use
Internal
Save the new project data by choosing Save All Metadata from the toolbar.
Only
Internal
Only
Select
Partner
Use
Startup Plug Default
and choose Finish.
SAP
SAP
Successful result:
The generated Web Dynpro application object completes your project structure. You
Partner
can now deploy your project and start your Web Dynpro application.
Use
Only
To deploy and run the application, choose Deploy new Archive and Run.
Successful result:
Internal
Only
Use
node Person, defined in the views context.
The values are then copied programmatically to
the elements of the value node People, defined in
SAP
SAP
Partner
Use
Internal
Only
6-1-1 Define the data transport from the view TableView to the view
TableDetailView.
To transport the person detail data between the two views, it is necessary to define the
People context node in the TableDetailView context and map the node to the
corresponding node in the component controller context.
- Define the context mapping between the context of the view TableView and the
component controller context.
Internal
Only
Use
SAP
SAP
Partner
(TableDetailView context).
Use
Internal
Only
Check the node People. This will also check all
child attributes.
Save the new project data by choosing Save All Metadata from the toolbar.
Internal
Only
6-1-2 Add input fields for all context elements to the detail view TableDetailView.
Apply the template Form to define input fields and labels.
Partner
Use
Expand the nodes JA310_WD_UIElements_2T / Web Dynpro / Web Dynpro
Components / Ex6Comp.
SAP
Select the node Views and open the context menu of view TableDetailView.
SAP
Choose Edit.
Partner
Use
Only
the SAP NetWeaver Developer Studio.
Choose Next.
Internal
Only
Choose Finish.
Use
SAP
SAP
Successful result:
Partner
Use
Save the new project data by choosing Save All Metadata from the toolbar.
Only
Internal
Only
Choose TableDetailView
Choose Finish
Partner
Use
From to
Outbound plug Inbound plug
toDetailView fromTableView
SAP
SAP
toTableView fromDetailView
Partner
Use
Internal
In TableView
Only
Choose the Action tab.
Define a new Action ShowDetailView (fires plug
toDetailView).
Internal
Only
Partner
Use
In TableDetailView
SAP
SAP
Partner
Use
Only
Choose the following properties:
Event onAction ShowDetails
Save the new project data by choosing Save All Metadata from the toolbar.
Successful result:
Internal
Only
Partner
Use
SAP
SAP
Partner
Use
Internal
Only
6-2-1 Define a toolbar for the table in the view TableView. Add a toolbarButton to the
toolbar.
Internal
Only
Use
choose Insert Toolbar.
SAP
SAP
Partner
Use
Choose Finish.
Internal
Save the new project data by choosing Save All Metadata from the toolbar.
Only
Internal
Only
Choose Finish.
Use
Update the properties of the toolbar button:
Event onAction DeleteEntry
Text Delete Entry
SAP
SAP
Partner
Use
Save the new project data by choosing Save All Metadata from the toolbar.
Internal
Only
Internal
Only
Save the new project data by choosing Save All Metadata from the toolbar.
Partner
Use
Take a look at exercise 5.
SAP
SAP
Successful result:
Partner
Use
Only
6-3-1 Update the structure Person in the local dictionary. Add an additional attribute
DURATION (type long).
Internal
Only
Use
Save the new project data by choosing Save All Metadata from the toolbar.
SAP
SAP
Partner
Use
Only
Choose the node People, open the context menu and
choose Edit Structure Binding.
Internal
Only
Use
SAP
SAP
Partner
People of the view context (left side).
Use
Press Finish.
Internal
Only
On the next screen choose DURATION and press
OK.
Save the new project data by choosing Save All Metadata from the toolbar.
Internal
Only
Partner
Save the new project data by choosing Save All Metadata from the toolbar.
Use
- Implement the generated method getPeopleDURATION(…).
SAP
SAP
In the context editor choose the IMPLEMENTATION tab and navigate to the method
getPeopleDURATION(…):
Partner
Use
package com.sap.training.ja310.wd_uielements_2opt3;
//@@begin imports
import java.sql.Date;
Internal
import java.util.Calendar;
import java.util.GregorianCalendar;
import com.sap.training.ja310.wd_uielements_2opt3
Only
.wdp.IPrivateEx6Comp;
//@@end
...
public long getPeopleDURATION(IPrivateEx6Comp
.IPeopleElement element)
{
//@@begin getPeopleDURATION(...)
// Get values of element attributes DATE_BEGIN and DATE_END
Date dateBegin = element.getDATE_BEGIN();
Date dateEnd = element.getDATE_END();
//@@end
Internal
Only
Save the new project data by choosing Save All Metadata from the toolbar.
Partner
6-3-4 Update the table on the view TableView: Add additional columns to display the
attributes DATE_BEGIN, DATE_END, and DURATION from the structure
Use
People.
SAP
SAP
Partner
Use
Only
Choose Finish.
Internal
Only
Partner
Save the new project data by choosing Save All Metadata from the toolbar.
Use
6-3-5 Build, deploy and run the application.
SAP
SAP
Partner
Use
Successful result:
Only
The duration is calculated as the difference between
the start date and the end date.
Contents:
z Introduction to Internationalization
z Message Editor
z IWDMessageManager class
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Internationalization
Partner
Due to the fact that “Internationalization” is such a long word, it is often abbreviated to “I18N”. That is,
Use
the first letter “I”, the last letter “N”, and don’t bother about the 18 other letters in between!
Internal
Only
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
.xlf files are stored in src/packages/{pkgn}/…/{pkg1}
Use
When creating the archive for a Web Dynpro project, a standard .properties file is derived from the
content of all .xlf files (per language).
.properties files are stored in gen_wdp/packages/{pkgn}/…/{pkg1}/wdp
Internal
Only
Internal
Only
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
View {nv}.wdview.xlf
{nv}.wdcontroller.xlf
Window {w}.wdwindow.xlf
Internal
Only
SimpleType {st}.dtsimpletype.xlf
Partner
Use
SAP AG 2004
SAP
SAP
The version of the NetWeaver Developer Studio shipped with the NetWeaver ’04 release does not
Partner
currently have any tools for translation support. The following example illustrates the manual process
Use
required for translation. Lets say that a project has been created in British English, and all its text must
be translated to German.
y In the Navigator View, locate all the relevant .xlf files under the directory
src/packages/{pkgn}/.../{pkg1}.
Internal
y Using the context menu copy and paste each file making sure that you rename the copied file
correctly! If {file}.xlf is the name of the file in the project language and {iso} indicates the
Only
ISO code for your required language or dialect, the name of the copied file follows the following rule:
{file}.xlf Æ {file}_{iso}.xlf
y Once the files have been copied correctly, the contents can be edited by double clicking on the .xlf
file name and the S2X editor will open. The text values can then be translated manually.
y Finally, you have to rebuild the Web Dynpro Project and create the archive. This will create the
.properties files used at runtime.
Important!
You may only translate Web Dynpro projects into those languages and dialects supported by standard
SAP systems!
Developer en de fr it ru jp en
Authenticated de fr it ru jp de
Anonymous fr it ru jp fr
Internal
Only
Anonymous it ru jp it
Anonymous ru jp ru
Anonymous jp jp
Partner
Use
SAP AG 2004
SAP
SAP
Partner
The session locale is the locale that is specified for the current user by the user management engine
Use
y Otherwise the default locale specified in the application properties is returned if existing.
y Otherwise the default locale specified in the Web Dynpro system properties is returned if existing.
y Otherwise the default locale of the VM is returned.
Only
The locale calculated by the Web Dynpro Runtime (last column) is passed to the
java.lang.ResourceBundle class loaded by the SAP J2EE Engine. This class uses the following fallback
sequence to load a physically existing resource bundle:
y load resource bundle for WD calculated locale
y if not existing: load resource bundle for the default locale of the VM
y if not existing: load resource bundle without language suffix, which always exists
z Use the Message Editor to create and edit messages that you
want to display on the screen
Internal
Only
Use
SAP AG 2004
SAP
SAP
Message Editor
Partner
The message editor will create 4 different types of message – Standard, Warning, Error and Text.
Use
The first three message types (Standard, Warning and Error) are used for supplying information to the
screen in the form of messages. Any message declared as one of these types will be created as a Java
constant in the class IMessage{nc}.
Internal
Messages of type Text are not created as Java constants within class IMessage{nc}. Messages of type
Only
Text should be used to stored the values for UI elements such as Captions and TextViews. These
values can be accessed through class IWDTextAccessor.
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
The class IWDTextAccessor can be used to access all texts defined in the components message pool.
Use
Only
Internal
Only
Use
SAP AG 2004
SAP
SAP
Partner
By default, when messages are sent to the UI, they will appear as a table in the bottom left of the screen.
Use
Only
Internal
Only
Use
SAP AG 2004
SAP
SAP
Partner
y It is often useful to create a class wide variable for the component’s message manager. That way,
Use
every method in the current controller has a single point of access to the message manager.
y The message manager is capable of terminating navigation! When an outbound navigation plug is
fired, the a special asynchronous navigation event is raised. During a single request/response cycle,
multiple navigation events could be raised. All these events are placed into a navigation queue that is
Internal
processed once the wdDoBeforeNavigation() method has been called. If you call the message
manager with a cancelNavigation value of true, then irrespective of the number of navigation
Only
events in the queue, the entire queue is ignored!
y Class IMessage{nc}.java will contain all the declared messages of type Standard, Warning and
Error within the component’s message pool. These can be returned as objects of type IWDMessage.
y IWDMessageManager.report*() methods add a message to the message manager’s message
table and return control to the calling program.
Internal
Only
IWDMessageManager.
Partner
Use
SAP AG 2004
SAP
SAP
Partner
If the user enters an invalid value into a UI element, then when the IWDMessageManager is told to
Use
report an error, it can be passed the context metadata of the attribute to which the UI element is bound.
By this way, the IWDMessageManager is able to establish a link between the text of the error
message appearing on the screen, and the UI element containing the invalid value.
Internal
The user can then click on the error message and the cursor will be repositioned on the offending field.
Only
Internal
Only
IWDAttributeInfo attrInfo =
wdContext.node{cn}.getNodeInfo().
getAttribute({ca});
I{cn}Element nodeElement =
wdContext. node{cn}.current{cn}Element();
Use
SAP AG 2004
SAP
SAP
Partner
y If a message is reported with reference to the context, the UI Element bound to the context element is
Use
Only
wdComponentAPI.getMessageManager()
.raisePendingException();
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
and do not return control to the calling program. This causes a forcible termination of user coding in the
Use
current controller in the same way that the ABAP statement RAISE immediately terminates an ABAP
program.
Internal
Only
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
1 Development Objectives
Messages
Partner
The Web Dynpro runtime environment provides generic UI services, which enables the
application developers to display messages of different types in the Web browser. It is
possible, that several messages are displayed at the same time. Some of these messages
Use
may be error messages.
The messages are displayed as hyperlinks. When clicking one of these links, an input
recommendation describing how to correct the error in the corresponding UI element is
automatically displayed.
SAP
SAP
2 Result
Partner
Use
Only
Optional Part I:
Template Solution:
WD Project: JA310_WD_Messages_opt1
Application: JA310_WD_Messages
Internal
Only
Starting point:
Go on with your WD Project: JA310_WD_Messages_T
Or start from the template solution: JA310_WD_Messages.
Template Solution:
WD Project: JA310_WD_Messages_opt2
Use
Application: JA310_WD_Messages
Starting point:
Go on with your WD Project: JA310_WD_Messages_T
SAP
Or start from the template solution: JA310_WD_Messages_opt1.
SAP
Partner
Use
Internal
Only
Internal
Only
Use
SAP
SAP
Partner
Use
Navigation:
StartView
Inbound and outbound plugs are
predefined.
Internal
TableView
Inbound and outbound plugs are
Only
predefined.
Context Mapping
StartView
The view context and context
mapping are predefined.
TableView
The view context and context
mapping are predefined.
4-1 Create the Web Dynpro application JA310_WD_Messages, deploy and run the Web
Dynpro application. The following screen appears:
Internal
Only
4-2-1 Define two new error messages with the Message Editor.
The first message shall be displayed, if a mandatory field has no value. Use
Use
a placeholder to allow displaying the name of the mandatory field.
The second message shall be displayed, if the date is in the past. Use two
placeholders to allow displaying the field name and the field value in the
message.
SAP
SAP
Partner
4-3-2 Implement the method checkMandatory:
Use
Only
- Now define an object of Type IWDAttributeInfo and get a reference to
the fields attributes.
- If no value was entered by the user (field length equals 0), use the
Method reportContextAttributeMessage of the message manager to
define the resulting message.
4-3-3 Implement the method checkDateIsInPast:
- First define a variable of Type IWDMessageManager and get a
reference to the components message manager.
- Next define a variable of Type Date (java.util.sql) and get the attribute
value of the field under consideration. Here, the Method
getAttributeValue() of the element at the lead selection can be used.
However, because the returned value is of the generic type Object, the
result has to be casted to type Date.
Internal
Only
Use
SAP
SAP
Partner
Use
Internal
Only
6-1 Define checkDateIsValid(). This method checks, if a date input field contains a
valid value.
6-1-1 Define a new error message DataIsNotValid without placeholders.
6-1-2 Define the method checkDateIsValid (Parameter fieldname, Type String).
6-1-3 Implement the method checkDateIsValid. Here the method
DateCalculater.isValid (Parameter dt, Type Date) can be used.
6-1-4 Update the Method onActionShowTableView(). Check if the values of both
Date fields are valid dates.
6-2 Build, deploy and run the application.
Internal
Only
Use
7-1-2 Define the method checkDateRange.
7-1-3 Implement the method checkDateRange. If an error is found, this error shall
be bound to the field for the end date. Here the method
SAP
DateCalculater.isAfter (Parameter d1 and d2, both Type Date) can be used.
SAP
Partner
Use
Internal
Only
4 Developing, Step-by-Step
Note: In this exercise you have to type in some lines of java code. For your convenience,
you can cut and paste the code from the corresponding solution project.
Internal
Only
But keep in mind: Some of the methods are automatically generated by Web Dynpro .
For this reason, the methods names you have to choose can differ from the method
names of the solution.
Partner
Use
4-2-1 Define two new error messages with the Message Editor.
SAP
SAP
Partner
Choose Open Message Editor.
Use
Only
Define the following messages:
Save the new project data by choosing Save All Metadata from the toolbar.
Internal
Only
Use
Save the new project data by choosing Save All Metadata from the toolbar.
SAP
SAP
Partner
Use
Only
Internal
Only
.getMessageManager();
.nodePerson()
.currentPersonElement()
.getAttributeAsText(fieldname);
Use
// Get field properties of attribute under investigation
IWDAttributeInfo personAttr = wdContext
SAP
.nodePerson()
SAP
.getNodeInfo()
.getAttribute(fieldname);
Partner
// Check if any input is provided
Use
if (value.length() == 0) {
Only
wdContext.nodePerson().currentPersonElement(),
personAttr,
IMessageEx7Comp.MISSING_INPUT,
new Object[] { fieldname },
true);
}
//@@end
}
You can implement the code to check the date on your own or you can use the Helper
class com.sap.training.ja310.wd_messages_t.util.DateCalculator.
This predefined class contains some static methods to check a dates.
Internal
Only
Use
.getAttributeValue(fieldname);
SAP
SAP
Partner
Use
Only
wdContext.nodePerson().currentPersonElement(),
personAttr,
IMessageEx7Comp.DATA_IS_IN_PAST,
new Object[] { fieldname, usrDate },
true);
}
//@@end
}
Internal
Only
// Output Messages
wdComponentAPI
.getComponent()
Partner
.getMessageManager()
.raisePendingException();
Use
// Check if the dates were provided and if these dates are
// valid (not in the past)
this.checkDateIsInPast("DATE_BEGIN");
SAP
SAP
this.checkDateIsInPast("DATE_END");
// Output Messages
Partner
Use
wdComponentAPI
.getComponent()
.getMessageManager()
Internal
.raisePendingException();
Only
// Navigation will only take place, if all values are valid
wdThis.wdFirePlugToTableView();
//@@end
}
Internal
Only
Select
Web Dynpro Component Ex7Comp
Use
Interface View Ex7CompInterfaceView
Startup Plug Default
and choose Finish.
SAP
SAP
Successful result:
The generated Web Dynpro application object completes your project structure. You can
now deploy your project and start your Web Dynpro application. JA310_WD_Messages
Partner
Use
enables you to address the Web application as a whole, when you launch this complete
application in the next step.
Internal
Only
Successful result:
Internal
Only
Use
button. An error message should appear.
Insert a date in the past (or no date at all) in
the DATE_BEGIN field and choose the Insert
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
Use
Save the new project data by choosing Save All Metadata from the toolbar.
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
.getAttributeValue(fieldname);
Use
// Check if date is valid
if (!DateCalculator.isValid(usrDate)) {
SAP
SAP
Partner
Use
wdContext.nodePerson().currentPersonElement(),
personAttr,
IMessageEx7Comp.DATA_IS_NOT_VALID,
new Object[] { fieldname, usrDate },
Internal
true);
}
Only
//@@end
}
Save the new project data by choosing Save All Metadata from the toolbar.
// Output Messages
wdComponentAPI
.getComponent()
Internal
Only
.getMessageManager()
.raisePendingException();
this.checkDateIsValid("DATE_BEGIN");
this.checkDateIsValid("DATE_END");
Use
wdComponentAPI
.getComponent()
.getMessageManager()
.raisePendingException();
SAP
SAP
Partner
Use
this.checkDateIsInPast("DATE_END");
// Output Messages
Internal
wdComponentAPI
.getComponent()
.getMessageManager()
Only
.raisePendingException();
Internal
Only
For detailed information about the necessary steps have a look at exercise 4-3-1.
Return Type Name Parameters
Use
void checkDateRange String fieldname_low,
String fieldname_high
SAP
Save the new project data by choosing Save All Metadata from the toolbar.
SAP
Partner
Use
Internal
Only
...
Internal
.currentPersonElement()
Only
.getAttributeValue(fieldname_low);
Date usrDate_high =
(Date) wdContext
.nodePerson()
Partner
.currentPersonElement()
.getAttributeValue(fieldname_high);
Use
// Get field properties of DATE_HIGH attribute
IWDAttributeInfo personAttr =
wdContext
SAP
SAP
.nodePerson()
.getNodeInfo()
.getAttribute(fieldname_high);
Partner
...
Use
if (DateCalculator.isAfter(usrDate_low, usrDate_high)){
Only
// If not: report error message
msgMan.reportContextAttributeMessage(
wdContext.nodePerson().currentPersonElement(),
personAttr,
IMessageEx7Comp.END_DATE_BEFORE_START_DATE,
new Object[] { usrDate_high, usrDate_low },
true);
}
//@@end
}
Save the new project data by choosing Save All Metadata from the toolbar.
...
Internal
Only
// Output Messages
wdComponentAPI
.getComponent()
Partner
.getMessageManager()
.raisePendingException();
Use
// Check if date range is valid
this. checkDateRange("DATE_BEGIN", "DATE_END");
SAP
SAP
// Output Messages
wdComponentAPI
.getComponent()
Partner
Use
.getMessageManager()
.raisePendingException();
Internal
...
Only
// Navigation will only take place, if all values are valid
wdThis.wdFirePlugToTableView();
//@@end
}
Contents:
z Three Types of Value Help.
z Defining a static Simple Type containing a value set.
z Simple Value Selector:
Populating a DropDownByKey UI element.
z Extended Value Selector:
Internal
Only
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
z Starting point:
A dictionary simple type containing an
enumeration.
z Simple Value Selector (SVS)
Dictionary simple type bound to a
DropDownByKey UI Element.
Suitable for small sets of values (< 30)
z Extended Value Selector (EVS)
Internal
Only
Use
z If required, the enumeration of the dictionary simple type can be modified at
runtime.
SAP AG 2004
SAP
SAP
Generic UI Services
Partner
The Web Dynpro runtime environment provides generic UI services for the application development.
Use
They enable you to easily create a value help for constants – for example, for countries or zip codes.
Simple Value Selector (SVS)
You can use the simple value selector as a dropdown list box to display a set of constants when you bind
a DropDownByKey UI element to a value attribute defined as a dictionary Simple Type. The simple
Internal
value selector is especially useful for small sets of constant values (up to 30 entries).
Extended Value Selector (EVS)
Only
If the number of entries in the dropdown list becomes too large to be useable, then you should use the
extended value selector instead. This value selector can display a large set of constants in a special
dialog box below a regular input field. The extended value selector also provides a sort function and
search function.
The main concept of this value help is to bind constants to an InputField or a DropdownByKey UI
element. The constants are contained in a dictionary Simple Type and the value attributes have the same
type. With the exception of the possible dynamic data type modifications of a value attribute at runtime,
the application developer need only implement the declarations involved.
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
In many application scenarios an additional type of value help is needed for searching objects instead of
Use
values. Think of searching for a Airline ID. For finding this ID you want to enter some related data like
departure and arrival airport or the flight date in a search form. The search results (matching flight
objects) are displayed in a table and after selecting a flight the airplane ID (or other values) is (are)
automatically transferred to the corresponding input field(s). For this purpose Web Dynpro provides a
Internal
third type of generic value help service called OVS (Object Value Selector).
In contrast to SVS and EVS the Object Value Selector is not completely based on a declarative
approach. For embedding this sophisticated value help into your Web Dynpro application you have to
Only
implement some lines of code in an associated OVS custom controller. Once defined, the Web Dynpro
Framework automatically renders a generic OVS pop-up window for you.
The OVS user interface is based on a core component belonging to the Web Dynpro Java Runtime
Environment.
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Context Metadata
Internal
Only
Java Dictionary
Results in
Partner
tains
Con
Use
Design Time Runtime
SAP AG 2004
SAP
SAP
Partner
At design time, a dictionary simple type is created that contains an enumeration. In this example the
Use
When the screen is rendered, the drop down list will automatically be populated with the values found in
Only
the simple type’s enumeration. The user will see the description of the enumeration value in the drop
down list, but when the view controller accesses the context attribute, it will pick up the value of the
selected enumeration item, not the description.
A Simple value selector is suitable when you want to display a small number (<30) of values. The values
in the simple type can be modified at runtime using the ISimpleTypeModifiable class.
Context Metadata
Internal
Only
Java Dictionary
Results in
Partner
tains
Con
Use
Design Time Runtime
SAP AG 2004
SAP
SAP
Partner
At design time, a dictionary simple type is created that contains an enumeration. In this example the
Use
When the screen is rendered, the input field will have a selector icon next to it. When this is clicked on,
Only
the eunmeration values from the dictionary simple type will be displayed as a table.
An extended value selector is suitable when you want to display a larger number (>30) of simple values.
The values in the simple type can be modified at runtime using the ISimpleTypeModifiable class.
View Layout
Dynamic creation of a modifiable simple type
Context Metadata // Get the metadat a for no de S elec tion Values
IWDNodeInf o selVal sNod eInfo = wdConte xt.n odeS elec tionValu es().get Node Info();
Internal
Only
Context Root ISimpleTyp eModifia ble msType = attrInf o.ge tMod ifia bleSimpl eType();
Acts on
IModifiabl eSimpleV alue Set valu eSet = m sTyp e.ge tSVS ervices( ).getMod ifia bleSimpl eValueSe t();
Results in
valueSet.p ut("Colo ur_1 4", "Sky Blue");
Partner
Use
Design Time Runtime
SAP AG 2004
SAP
SAP
Partner
A dynamic extended value selector is the result of implementing runtime coding that alters a context
Use
attribute’s modifiable simple type. The coding is discussed on the following slide.
Principles of using a dynamic extended value selector
y If you dynamically alter the modifiable simple type associated with a context attribute of type
string, then the selection table will contain only those entries you have added through your runtime
Internal
coding.
y If however, you alter the modifiable simple type associated with a context attribute that already has an
Only
enumeration, then any values added at runtime will be appended to the existing enumeration. Thus the
extended value selector table will display the sum of the two sets of enumeration items.
However, an existing enumeration can also be cleared, before adding new values at runtime.
Internal
Only
valueSet.put("Colour_12", "Saffron");
valueSet.put("Colour_13", "Lime");
valueSet.put("Colour_14", "Sky Blue");
Use
valueSet.put("Colour_15", "Turquoise");
valueSet.put("Colour_16", "Purple");
SAP AG 2004
SAP
SAP
Partner
In the above example, a context node called SelectionValues contains a string attribute called
Use
Colours. Since this attribute is of type string, it has no predefined enumeration, therefore, we need to
create one at runtime.
Whatever values are added to this modifiable simple type become the selection values shown in the
Internal
Only
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
1 Development Objectives
Value Help
Partner
The Web Dynpro runtime environment provides generic UI services for the application
development. They enable you to create a value help for constants easily – for example, for
Use
countries or zip codes. You can use the simple value selector as a dropdown list box to
display a set of constants when you bind a DropdownByKey UI element to a value attribute
of the type Simple Type. The simple value selector is especially useful for small sets of
constant values (up to 30 entries).
SAP
SAP
2 Result
Partner
Use
Only
restricted to key entries of a predefined set
of constants from the Java Dictionary.
Optional Part:
Template Solution:
WD Project: JA310_WD_GenUI_opt
Application: JA310_WD_GenUI
Internal
Only
Starting point:
Go on with your WD Project: JA310_WD_GenUI_T
Or start from the template solution: JA310_WD_GenUI
Partner
3 Prerequisites
Use
You have launched the SAP NetWeaver Developer Studio.
You have selected the Web Dynpro perspective.
You have opened the JA310_WD_GenUI_T project.
The structure this project is currently displayed in the Web Dynpro Explorer.
SAP
SAP
Partner
Use
Only
4-1 Define a simple data type called VehicleType in the Java Dictionary. Add five car
types to the data type:
Value Description
CMPC Compact
ECNM Economy
LXRY Luxury
MNVN Minivan
PRMM Premium
Internal
Only
4-2 Declare a value attribute VhclType of the type VehicleType as a child of the value
node ReservationInfo in the context of the view controller.
4-3 Define a DropDownByKey UI element with a corresponding Label in the Layout of
the view controller. There is a group element already definied, which will serve as a
Partner
container (grp_vhclType).
Define the data binding between the DropDownByKey UI element and the value
attribute VhclType.
Use
4-4 Create the Web Dynpro application JA310_WD_GenUI.
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP
SAP
6-1 In the view controller context, declare a new value node having the name Image as
Partner
Use
a child node of the value node ReservationInfo. Set the cardinality of this node to
1..1.
Define three attributes ImgAlt, ImgSrc (both type string), and ImgVisible (type
sap.com.ide.webdynpro.uielementdefinitions.Visibility) as child attributes of the
Internal
Only
it (properties alt, source, and visible).
The image is not visible, when the application starts. After the user has selected a
value from the simple value selector a corresponding image should appear (after
having completed the next steps).
6-3 Define a new action ShowImg and assign this action to the DropDownByKey UI
element. The corresponding method is called automatically, when the user selects a
new value from the simple value selector.
6-4 Implement the Method onActionShowImg(): Define the images name from the entry
in the DropDownByKey UI element, by adding the ending .gif.
Assign the image name to the property attributes alt and source. Set the visibility to
WDVisibility.VISIBLE.
6-5 Build, deploy and run the application.
4 Developing, Step-by-Step
4-1 Define a Simple Type data type called VehicleType in the Java Dictionary.
Internal
Only
Use
Name VehicleType
Package com.sap.training.ja310.wd_genui_t
.simpletypes
SAP
SAP
Partner
In the Data Type Editor, choose the tab
Use
CMPC Compact
ECNM Economy
Only
LXRY Luxury
MNVN Minivan
PRMM Premium
Save the new project data by choosing Save All Metadata from the toolbar.
Name VhclType
Internal
Only
Type com.sap.training.wd_genui_t.
simpletypes.VehicleType
Use
Save the new project data by choosing Save All Metadata from the toolbar.
SAP
SAP
Partner
Use
Only
Choose RootUIElementContainer /
grp_inpFields_reservation / grpVhclType.
Internal
Only
Save the new project data by choosing Save All Metadata from the toolbar.
Partner
Use
In the Web Dynpro Explorer, expand the node JA310_WD_GenUI_T.
Expand the node Web Dynpro and open the context menu for Applications.
To open the wizard, choose Create Application.
SAP
SAP
Partner
Use
Package com.sap.training.ja310.wd_genui_t
Only
Select
Web Dynpro Component Ex8Comp
Interface View Ex8CompInterfaceView
Startup Plug Default
and choose Finish.
Successful result:
The generated Web Dynpro application object completes your project structure. You can
now deploy your project and start your Web Dynpro application. JA310_WD_GenUI
enables you to address the Web application as a whole, when you launch this complete
application in the next step
Successful result:
Internal
Only
Use
SAP
SAP
Partner
Use
Internal
Only
6-1 In the view controller context, declare a new value node having the name Image….
Internal
Only
Partner
Use
Set the cardinality of the value node Image to the
value 1..1.
SAP
SAP
Partner
Use
Internal
Only
Choose RootUIElementContainer /
grp_inpFields_reservation / grpVhclType.
Internal
Only
Use
alt ReservationInfo.Image.ImgAlt
source ReservationInfo.Image.ImgSrc
visible ReservationInfo.Image.ImgVisible
SAP
SAP
colspan 2
Partner
Use
6-3 Define a new action ShowImg and assign this action to the DropDownByKey UI
element.
Internal
Only
name ShowImg
event handler use default
fire plug None
Choose RootUIElementContainer /
grp_inpFields_reservation / grpVhclType.
Internal
Only
onSelect ShowImg
Partner
Save the new project data by choosing Save All Metadata from the toolbar
Use
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
.nodeReservationInfo()
.currentReservationInfoElement()
.getVhclType();;
Partner
Use
wdContext.nodeImage()
.currentImageElement()
.setImgAlt(imgName+".gif");
SAP
SAP
wdContext.nodeImage()
.currentImageElement()
.setImgSrc(imgName+".gif");
Partner
Use
wdContext.nodeImage()
.currentImageElement()
.setImgVisible(WDVisibility.VISIBLE);
Internal
//@@end
Only
}
The last JAVA statement changes the visibility of the image, by changing the value of
the context attribute, which is bound to the property attribute visibility.
Here, not a build in data type can be used, but one defined in the dictionary
com.sap.ide.webdynpro.uielementdefinitions.
Save the new project data by choosing Save All Metadata from the toolbar.
Successful result:
Internal
Only
Partner
Use
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
1 Development Objectives
Value Help
Partner
The Web Dynpro runtime environment provides generic UI services for the application
development. They enable you to create a value help for constants easily – for example, for
Use
countries or zip codes. The extended value selector can be used as a value selector for a
large number of constants. Inserting an extended value selector is similar to inserting a
simple value selector. The difference is that instead of a DropDownByKey UI element, an
SAP
InputField UI element is bound to a value attribute whose data type is of the type Simple
SAP
Type. You can define the data type Simple Type in the Java Dictionary at design time or
you can create it using the ISimpleTypeModifiable interface for modifying the data type of
a value attribute at runtime. This interface does not provide the required metadata until
runtime. The main binding mechanisms are retained in this process.
Partner
Use
2 Result
Internal
Only
locations) that you’ve defined in the Java
Dictionary at design time.
Optional part:
You will learn, how allowed value
attributes can be can be added to the EVS
dynamically.
Optional Part:
Template Solution:
WD Project: JA310_WD_GenUI_2opt
Application: JA310_WD_GenUI
Internal
Only
Starting point:
Go on with your WD Project: JA310_WD_GenUI_T
Or start from the template solution: JA310_WD_GenUI_2.
Partner
3 Prerequisites
You have launched the SAP NetWeaver Developer Studio.
Use
You have selected the Web Dynpro perspective.
You have opened the template project JA310_WD_GenUI_opt, or you go on working with
your last WD Project JA310_WD_GenUI_T.
The structure this project is currently displayed in the Web Dynpro Explorer.
SAP
SAP
Partner
If you have finished the previous exercise
Use
Only
Internal
Only
4-2 Declare a value attribute CityFrom and CityTo (each of it type: Cities_All) as
childes of the node ReservationInfo in the context of the view controller.
4-3 Define two InputField UI elements with corresponding Labels for the pickup
location CityFrom and drop down location CityTo. Define these elements in the
pre-defined group UI element grp_location using the Apply Template functionality.
Partner
Use
5 Overview: Building, Deploying, and Running
Deploy and run the Web Dynpro application.
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
Partner
Use
6-1 Define a simple data type called Region. Create some entries. The region values
must equal the city prefix from exercise 4-1:
SAP
SAP
EUR Europe
AMS South America
Partner
AMN North America
Use
OCE Oceania
ASA Asia
Internal
AFR Africa
6-2 Define a new value attribute Region as child of the value node ReservationInfo in
Only
the context of the view controller (type Region).
6-3 Define a new radio button group UI element RadioButtonGroupByKey in the pre-
defined group UI element grp_location. Bind the property selectedKey to the
context field Region.
6-4 Define a new action FilterCities. Bind this action to the property onSelect of the
RadioButtonGroup. The corresponding Method will be processed after the user
selects an entry from the RadioButtonGroup.
6-5 Declare a helper method fillValueSet to fill the value selector. This method shall be
called at start time and after the selection of the RadioButtonGroup.
At start time the simple value selector for pickup and dropdown location shall
contain all cities. After having selected a region from the RadioButtonGroup, the
value selector for these two InputFields should only contain cities of the selected
region.
© SAP AG JA310 8-28
6-5-1 Declare the helper method fillValueSet (Parameter Boolean initialize).
The parameter initialize will be used to provide the information, if all cities
shall be selected (initialize=true) or only the city which correspond to the
selected region shall be selected (initialize=false).
6-5-2 Implement the Method onActionFilterCities. Call the method
fillValueSet(false).
6-5-3 Define a new value attribute CitiesAll (type: Cities_All) as child of the value
node ReservationInfo in the context of the view controller. The enumeration
of the related data type will hold all possible cities for all regions.
6-5-4 Implement the method fillValueSet.
- First define three helper variables:
The first variable (nodeInfo)shall hold a reference to the metadata of the
node ReservationInfo.
Internal
Only
Use
.getAttribute("<ctx_field>")
.getModifiableSimpleType()
.getSVServices()
.getModifiableSimpleValueSet()
SAP
SAP
Partner
Use
and CityTo.
Depending on the parameter initialize, only cities of a specified region
or all cities shall be copied.
6-6 Update the method wdDoInit(). At start time the value selector should contain all
Internal
Only
4 Developing, Step-by-Step
Note: In this exercise you have to type in some lines of java code. For your convenience,
you can cut and paste the code from the corresponding solution project.
Internal
Only
But keep in mind: Some of the methods are automatically generated by Web Dynpro.
For this reason the methods names you have to choose can differ from the method
names of the solution.
Note: The names of the WD project and of the package are based on the assumption,
Partner
that you start with the template solution WD project of the last exercise!
Use
4-1 Define a simple data type called Cities_All in the Java Dictionary.
SAP
Expand the nodes JA310_WD_GenUI_opt / Dictionaries / Local Dictionary / Data
SAP
Types.
Partner
Use
wd_genui_opt.simpletypes
Only
Internal
Only
ASA Asia
AFR Africa
Partner
Save the new project data by choosing Save All Metadata from the toolbar.
Use
4-2 Declare a value attribute CityFrom and CityTo (each of it type: Cities_All) as childes of
the node ReservationInfo in the context of the view controller.
SAP
SAP
Partner
Use
Only
CityFrom com.sap.training.ja310.
wd_genui_opt.
simpletypes.Cities_All
CityTo com.sap.training.ja310.
wd_genui_opt.
simpletypes.Cities_All
Save the new project data by choosing Save All Metadata from the toolbar.
Choose RootUIElementContainer /
grp_inpFields_reservation / grp_location
Internal
Only
Use
Fields CityFrom, CityTo
SAP
SAP
Partner
UI element (which is the default here) !
Use
Only
The propery text of the labels has to be adapted.
Save the new project data by choosing Save All Metadata from the toolbar.
© SAP AG JA310 8-32
5 Building, Deploying, and Running, Step-by-Step
Successful result:
Internal
Only
Use
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
In the Data Type Editor, choose the Enumeration tab and create some entries:
Value Description
OCE Oceania
Partner
ASA Asia
AFR Africa
Use
EUR Europe
AMB North America
AMS South America
SAP
SAP
Note: Use the same abbreviations as key as you have used as prefix for the cities data
type (see exercise 4-1).
Partner
Use
Save the new project data by choosing Save All Metadata from the toolbar.
Internal
6-2 Define a new value attribute Region as child of the value node ReservationInfo in the
context of the view controller (type Region).
Only
Take a look at exercise 4-2.
Choose RootUIElementContainer /
grp_inpFields_reservation / grp_location.
Internal
Only
Choose RadioButtonButtonGroupByKey
Use
Change the properties of the UI element:
colCount 2
SAP
SAP
selectedKey ReservationInfo.Region
Partner
Use
Save the new project data by choosing Save All Metadata from the toolbar.
Internal
Only
Internal
Only
Save the new project data by choosing Save All Metadata from the toolbar
Use
6-5 Declare a helper method fillValueSet to fill the value selector.
SAP
SAP
Partner
Use
In the view Editor of the view StartView, choose the tab Methods and add the method
public void fillValueSet(Boolean initialize).
Internal
Only
Internal
Only
initialize();
fillValueSet( false );
//@@end
Partner
Use
6-5-3 Define a new value attribute CitiesAll (type: Cities_All) as child of the value
node ReservationInfo in the context of the view controller.
SAP
SAP
Partner
Use
Internal
Only
Choose the tab Implementation, navigate to the generated method and implement the
method body.
Note: You can copy and paste the code from the solution project.
Internal
Only
Use
.getNodeInfo();
SAP
SAP
Partner
Use
.currentReservationInfoElement();
Only
..// Now get a reference to the enumeration related to the
// context value attributes CitiesAll, CityFrom and CityTo
IModifiableSimpleValueSet citiesAll_SV =
nodeInfo.getAttribute("CitiesAll")
.getModifiableSimpleType()
.getSVServices()
.getModifiableSimpleValueSet();
IModifiableSimpleValueSet cityFrom_SV =
nodeInfo.getAttribute("CityFrom")
Internal
Only
Use
// steps
String cityFrom = nodeElement.getCityFrom();
SAP
String cityTo = nodeElement.getCityTo();
SAP
Partner
// selected region -> clear
Use
if (cityFrom != null) {
if (!cityFrom.startsWith(region)) {
Internal
nodeElement.setCityFrom("");
}
}
Only
// OPTIONAL: If value of field CityTo does not fit to
// selected region -> clear
if (cityTo != null) {
if (!cityTo.startsWith(region) && !(cityTo == null)) {
nodeElement.setCityTo("");
}
}
Internal
Only
cityTo_SV.put(citiesAll_SV.getKey(i),
citiesAll_SV.getText(i));
}
Partner
}
//@@end
Use
}
Save the new project data by choosing Save All Metadata from the toolbar.
SAP
SAP
Partner
Use
fillValueSet( true );
//@@end
Only
}
Save the new project data by choosing Save All Metadata from the toolbar.
Internal
Only
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
Select the server node and from the right mouse click pop-up menu,
select “Enable debugging of process”. This will cause the server
node to restart in debug mode.
Use
However, if the J2EE is subsequently restarted, it will come back up
with debug mode switched off.
SAP AG 2004
SAP
SAP
Partner
The J2EE Engine view provides a context menu option for switching on debug mode. The server node
Use
of the J2EE engine will then remain in debug mode until it is next restarted, at which time it will come
up again with debug mode switched off.
Internal
Only
Internal
Only
3. Locate cluster_data
One of the configurations is called
cluster_data.
Expand this node and locate the
Partner
Use
bar and confirm the warning
message.
SAP AG 2004
SAP
SAP
Partner
The Visual Administrator tool allows you to configure all aspects of the J2EE Engine. Using this tool, it
Use
Only
Internal
Only
debug mode
Locate the server node’s
debug mode property.
Click once on the property
name.
Partner
Use
SAP AG 2004
SAP
SAP
Important
Partner
The dispatcher node of a J2EE cluster has an Id that ends in 00. The first server node has an Id that ends
Use
in 50.
Internal
Only
Internal
Only
Ö The server node will now come up in debug mode every time it is
started.
Partner
Use
SAP AG 2004
SAP
SAP
Important note!
Partner
In J2EE clusters in which there are multiple server nodes, switching on debug mode will remove that
Use
node from taking part in clustered load balancing. In other words, putting a server node into debug mode
instructs the message server to detach it from the cluster and reserves it for debug processing.
Only one debug session may be active on a server node at any one time.
Internal
Only
Double
click
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Setting a Breakpoint
Partner
y Open the implementation page of any controller from a given application.
Use
To do so, in the Web Dynpro Explorer, edit the Controller and go to the Implementation tab page.
y The Editor displays the source code. Navigate to wdDoInit() method. Right-click on the marker
bar (along the left edge of the editor area) frame next to line of code to open the context menu and
choose Add Breakpoint. You can also double click in the marker bar to achieve the same results. The
Internal
Only
You can also experiment with setting conditional breakpoints by setting the breakpoint properties from
the context menu
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
To start the Web Dynpro application in the debugger, you require a launch configuration.
Use
Only
Dynpro application to be debugged and confirm with OK.
y If the application to be debugged has not yet been deployed on the server, select the Create and
deploy archive checkbox.
y Press Apply.
y Optional: To select the server that you want to use for the debugging procedure, choose the J2EE
engine tab page.
y The configuration is now complete and you can start the debugger.
y To start the debugger, choose Debug and the NetWeaver Developer studio will switch automatically
to the debug view.
Variables View
Debug View
Internal
Only
Editor View
Partner
Use
SAP AG 2004
SAP
SAP
Partner
Once you have started the debugging process, Eclipse will switch to the debugging perspective.
Use
The Debug view is at the upper left of the perspectives. This view allows you to manage the debugging
or running of a program in the workbench. It displays the stack frame for the suspended threads for each
target you are debugging. Each thread in your program appears as a node in the tree. It displays the
Internal
Only
Breakpoints, Expressions, and Display. This view shows information about variables that are currently
in scope (currently-selected stack frame) for your program.
The Editor view - The Java editor provides you with Java specific text editing support. You will see the
program line the debugger is currently executing. If the execution of your program takes you to a
different class, Eclipse will open up the corresponding .java file automatically.
Console view - shows the output of a process and allows you to provide keyboard input to a process, but
this only works if you started the java process in eclipse. Debugging the server means that you attach to
the process remotely, therefore you will need to rely on the log files to see the process output.
Tip: If you rearrange the view you can restore the default settings by selecting Window → Reset
Perspective. You can obtain more information about any of the views by clicking on the title of the view
and pressing F1.
Suspend Terminate
Disconnect
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
The debug key assignments used in the NetWeaver Developer Studio are the same as the debug key
Use
assignments in ABAP.
Only
The current statement is executed in it entirety, that is, without entering any inner method calls.
Step Out (F7):
The current method is exited and you will traverse back to the calling method.
Resume (F8):
The application exits debug mode and continues with execution.
Suspend:
Will pause execution and allows you to view state of variables.
Terminate:
Will terminate execution of the program .
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
The Step With Filters button works like Step Into, but you can specify which methods Step Filter will
Use
execute and return from immediately by selecting ( Window → Preferences → Java → Debug → Step
Filtering) and defining step filters by checking the packages and classes listed there. This way you can
step only into methods in your own classes and not into the standard Java packages or third-party
packages.
Internal
Only
Click to expand
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Variables View
Partner
When the stack frame is selected, you can see the visible variables in that stack frame in the Variables
Use
view. The Variables view shows the value of primitive types. Complex variables can be examined by
expanding them to show their members.
Internal
Only
z Allows you to change code “on the fly” during your debug session
1. Change the code in the editor while you’re debugging
2. Save the file, then press the Resume button to get the Web Dynpro
Application running again with your changes
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Hot Swap
Partner
A new feature of JVM 1.4 (Java Virtual Machine) and Eclipse version of Netweaver Developer Studio
Use
is Hotswap Bug Fixing. JVM 1.4 is compatible with the Java Platform Debugger Architecture (JPDA).
The JPDA allows you to modify code in a running application. To use this debugging function, simply
change the code in the editor, save and resume debugging. This is a much easier approach than exiting
the app, changing the source code, recompiling, and then starting another debugging session.
Internal
With HotSwap, you can fix the problem on the fly while the debugger is still running!
Only
z Allows you to change code “on the fly” during your debug session
1. Change the code in the editor while you’re debugging
2. Save the file, then press the Resume button to get the Web Dynpro
Application running again with your changes
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Step 1
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Terminating Debugging
Partner
If you want to exit debugging, you must terminate the threads in the SAP NetWeaver Developer Studio.
Use
y In the Debug View, call the context menu for the top node (<Application Name>[Web Dynpro
Application]).
y Choose Terminate.
Internal
Only
Step 2
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Terminating Debugging
Partner
If you want to exit debugging, you must terminate the threads in the SAP NetWeaver Developer Studio.
Use
y In the Debug View, call the context menu for the top node (<Application Name>[Web Dynpro
Application]).
y Choose Terminate.
y Call the context menu again and then choose Remove All Terminated Launches. The Remove All
Internal
Terminated Launches tool button clears the Debug view of threads that have been terminated.
Only
Restart
Debugging
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
You can restart debugging of the application <Application Name> by choosing
Use
Only
03
Dispatcher
Internal
Only
Server 0
Server 1 Productive Nodes
...
Server N Run Debug
07
Partner
Use
SAP AG 2004
SAP
SAP
Debugging Scenarios
Partner
y Standalone developer workplace installation
Use
The Web AS is installed on the same local developer PC as the Developer Studio. By default, the
debugging mode is deactivated for this single server configuration. However, the server node
(server0) can be switched from run mode to debugging mode. This is the typical scenario for a
developer’s installation.
Internal
y LAN scenario
Web AS is installed at any location in the LAN. The Developer Studio and the server (including the
Only
database) are now installed on different hosts. In general, a LAN will feature a cluster configuration.
It defines a group consisting of several instance nodes. In such a cluster configuration, one or more
server nodes can be reserved for debugging. When debugging is activated the message server
deactivates the relevant server node for the cluster communication. As a result, incoming requests are
no longer passed on to the reserved node. A debugging session can be executed from within the
Developer Studio via the debug port without affecting the other server nodes in the cluster.
y WAN scenario
The Web AS runs on the customer side. Debugging takes place through firewalls using SAP Router
technology.
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
In order to debug ABAP code from a Web Dynpro application, you must meet the following
Use
prerequisites:
y The kernel parameter abap/ext_debugging_possible must be set to 0. This is the default
for a non-productive system.
y SAP GUI is installed on your local machine.
Internal
y The JCo connection used to connect to the SAP system connects directly to an application server (i.e.
does not use a logon group).
Only
y You have activated external debugging in the ABAP Workbench for the user used by the JCo
connection.
y You have logged on to the SAP system with the same user as the JCo connection, and set an external
breakpoint in the ABAP code.
Since debugging in the ABAP system via load balancing is not supported, you must create a special JCo
destinations in your J2EE engine that connects to a dedicated application server.
For further information, read the document “Debugging ABAP Code from within Web Dynpro
Applications” available in SDN.
For detailed information of how to set up external debugging of ABAP code, see Note 668256.
Internal
Only
Use
SAP AG 2004
SAP
SAP
Partner
No bugs have been harmed during the making of this presentation.
Use
Internal
Only
Internal
Only
1 Development Objectives
Partner
These short exercises will give practical hands-on experience using the debugger to change
program variables.
Use
SAP
2 Result
SAP
Partner
Use
Optional part:
You will learn how to change source code
on the fly in a debugging session
Only
3 Prerequisites
Internal
Only
Partner
4 Debugging, Step-by-Step
Use
4-1 Web Dynpro Debugging:
In the application JA310_WD_UIElements_2opt3, which is defined in the project
having the same name, the user can input some person data on the first screen. This
person information is then collected and displayed on a second screen using a
SAP
SAP
TableView UI element.
In this exercise, the debugger shall be used to manipulate the person's information,
which is displayed in the TableView element. This shall be realized by manipulation
the user input before storing it in the context node related to the TableView element.
Partner
Use
Only
4-1-4 Change the values of the attributes FIRSTNAME and LASTNAME in the
variable newPerson.
4-1-5 Terminate debugging.
4 Debugging, Step-by-Step
Internal
Only
debugging for the server process of the J2EE Engine. You activate this in the J2EE
Engine view.
If necessary, open the J2EE Engine view. To do so, choose Window → Show View →
Use
Other and then select J2EE → J2EE Engine.
SAP
SAP
Expand the tree display fully until you can see the
actual server process (for example server0).
Partner
Use
Internal
Only
4-1-2 Edit the view StartView and choose the Implementation tab. Navigate into the
Internal
Only
Use
Select the implementation tab to edit the views
cource code.
SAP
SAP
Partner
Use
Only
Internal
Only
Use
If the JA310_WD_UIElements_2opt3 application
to be debugged has not yet been deployed on the
server, select the Create and deploy archive
SAP
checkbox.
SAP
Partner
Use
Only
started in an external Browser. If the application
appears that it can no longer be executed, you
should switch back to the SAP NetWeaver
Developer Studio. You will see that the application
was stopped at the breakpoint and can now be
analyzed.
Internal
Only
Use
defined in the code.
SAP
SAP
Partner
Use
Internal
Only
Open the newPerson variable.
Internal
Only
Use
SAP
SAP
Partner
Use
Only
Now change the first name and last name stored in
the People node element.
Internal
Only
Proceed as follows:
Partner
In the Debug View, call the context menu for the top
node and choose Terminate.
Use
Call the context menu again and then choose
Remove All Terminated Launches.
SAP
SAP
Partner
Terminated.
Use
Internal
Only
Internal
Only
4-2-3 HotSwap
Partner
Use
After pressing Show Names, the data set is
displayed in the table.
SAP
SAP
Partner
Use
Only
to
wdThis.wdFirePlugToStartView();
Result: Your application should reflect your code changes. Instead of showing the
DetailView, the StartView is displayed again.
Contents:
z Introduction
z Modifying the context structure at runtime
z Modifying the UI Element hierarchy at runtime
z The use of dynamic actions
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Only
Internal
Only
Development Principle
Only if the required functionality of your application does not permit
Use
design time declarations, then use a dynamic modification approach.
SAP
SAP
SAP AG 2004
Partner
Use
However, it is perfectly possible to create a context and UI layout hierarchy at runtime. These techniques
should only be used when they are required!
Only
It is preferable to create as much of your context and UI layout hierarchy as possible at design time.
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Description (string)
ItemNo (int)
Internal
Only
Price (decimal)
Quantity (decimal)
OrderNo (int)
Partner
SalesDate (date)
SalesRep (string)
Use
LongText (string)
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
SalesDate (date)
relevant parameters.
SalesRep (string)
Use
LongText (string)
SAP
SAP
SAP AG 2004
Partner
Use
Only
Internal
Only
.addChild("SalesOrders", // Name
null, // Structure reference
true, // Is singleton?
false, true, // Cardinality
false, false, // Selection cardinality
true, // Initialise lead selection?
null, // Datatype
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
y Get a reference to the metadata of the node acting as the parent of the new node. In the case of an
independent node, this will be the metadata of the context root node.
y Node names must be unique within the scope of the entire context! You will get a runtime error in
Only
the context if you try to create a new node of the same name as one that already exists.
y When creating an independent node, it is forced to be a singleton; therefore, the third parameter (a
boolean) must be set to true.
Internal
Only
SalesDate (date)
datatype.
SalesRep (string)
Use
LongText (string)
SAP
SAP
SAP AG 2004
Partner
Use
Only
Internal
Only
salesOrdersInfo
.addAttribute("SalesDate","ddic:com.sap.dictionary.date");
salesOrdersInfo
.addAttribute("SalesRep","ddic:com.sap.dictionary.string");
Partner
z You may create an attribute of any data type you wish… but, if you
want to bind a UI element to the new attribute, then it must be
Use
created using a data type defined in the SAP Java Dictionary.
SAP
SAP
SAP AG 2004
Partner
Use
In order to display the data, then you must use one of the “ddic:com.sap.dictionary.*”
classes.
Only
A list of these types can be seen if you select a statically defined attribute from the context, then look at
the values in the drop down list against its datatype property.
Internal
Only
Use
LongText (string)
SAP
SAP
SAP AG 2004
Partner
Use
The general principle here is that an instance of the parent node must exist before a child node’s
metadata can be created. In the case of an independent node, the context root node (the parent node) can
always be assumed to exist, therefore, this step was not previously required.
Only
Internal
Only
.addChild("LineItems", // Name
null, // Structure reference
false, // Is singleton?
false, true, // Cardinality
false, false, // Selection cardinality
true, // Initialise lead selection?
null, // Datatype
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
parent node’s element collection that will act as the parent element for this new node. In cases where
the context root node is the parent, then this value will always be 0 since the context root node has one,
and only one element in its collection.
Only
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
SalesRep SalesDateLabel
LongText SalesDateInput
SalesRepLabel
Partner
SalesRepInput
LongTextLabel
Use
LongTextInput
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
SalesRep container
3. Define a layout
LongText
manager for the root
UI element container
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
if (firstTime) {
// Get a reference to the root UI element in the view
// layout hierarchy.
IWDTransparentContainer tCont =
(IWDTransparentContainer)view.getRootElement();
Partner
Use
...
}
SAP
SAP
SAP AG 2004
Partner
Use
When you wish to display the contents of a context attribute on the screen, the UI element that will
display the data must be bound to the context attribute in question. This binding relationship is most
Only
easily defined by associating the UI element with a reference to the metadata of the context attribute.
Hence the last line of coding in the code sample above.
Internal
Only
required
4. Add the Label object
to the root UI
Use
element container
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
// Switch off the vertical bar to the left of the label text
lab.setText(attrInfo.getName());
lab.createLayoutData(IWDMatrixHeadData.class);
lab.setDesign(WDLabelDesign.LIGHT);
Use
// Add the label to the root UI element container
tCont.addChild(lab);
SAP
SAP
SAP AG 2004
Partner
Use
Irrespective of the type of UI element you wish to create, createElement() will always return an
object of class IWDViewElement. This is the parent class for all other UI element objects and can be
Only
cast to the require type.
Internal
Only
properties as
required
4. Add the InputField to
Use
the root UI element
container
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
inFld.bindValue(attrInfo);
// Set the layout data to be a matrix row cell
inFld.createLayoutData(IWDMatrixData.class);
// Add the input field to the root UI element container
tCont.addChild(inFld);
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
For any UI element property {uip}, various methods will exist in the UI element’s class. Not all of the
methods listed below will exist for a given UI element property.
Only
void bind{uip}(String)
void bind{uip}(IWD[Attribute|Node]Info)
String bindingOf{uip}()
{dtp} get{uip}()
void set{uip}({dtp} value)
Where {uip} is the particular property of the UI element and {dtp} is the property’s data type.
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Declared actions
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Only
z Coding steps:
1. Obtain a reference to the action event handler.
2. Use the action event handler to create a runtime action object
3. Important! Make sure that the runtime action object is enabled.
4. Create a UI element (e.g. a checkbox)
5. Assign the runtime action object to the event handler of the UI
element’s onToggle event.
6. Add the UI element to the UI element hierarchy
Internal
Only
get reference
Event Handler
UI Element Hierarchy 1
Partner
RootUIElementContainer create
4
… create
assign enable
Use
cb Action Action 2
Checkbox1
6 5 3
add
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
IWDAction genericEventAction =
wdThis.wdCreateAction(actHandler,"Event text");
// Enable runtime action object
genericEventAction.setEnabled(true);
// Create a checkbox UI element
Partner
IWDCheckBox cb = (IWDCheckBox)view.createElement(IWDCheckBox.class,
"Checkbox1");
// Assign runtime action object to the checkbox UI element
Use
cb.setOnToggle(genericEventAction);
SAP
SAP
SAP AG 2004
Partner
Use
It is very important to enable a runtime action object! If you assign a disabled runtime action to a UI
element, then the UI element will become deactivated. This is also a powerful programming technique
for activating or deactivating groups of UI elements in a single statement.
Only
Unfortunately, as it stands, this coding has a couple of drawbacks!
z Using the example of a drop down list UI element, the server side
action handler will need to know which item in the list has been
selected.
This is achieved through parameter mapping.
z Many UI elements pass parameter values back to the Web Dynpro
server. These parameters must be identified and their values
obtained.
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
3
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
keyboard. Now, the class name appears as a link. Clicking on the link opens the source code of this
class.
y The method names that start mappingOf{uievt}() can be located in the Outline View. Clicking on
Only
these names repositions the source code of the element class in the editor.
y The parameter names are listed in the method’s comment block.
Internal
Only
* value.</li></ul>
*
* @return parameter mapping list.
Use
* @see #getOnSelect()
*/
public IWDParameterMapping mappingOfOnSelect();
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Partner
Use
Parameter for
receiving drop down
list index value
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
z Coding steps:
1.Obtain a reference to the UI element sending the parameter value
2. Define a mapping between the UI element parameter (first value) and the
action event handler parameter (second value)
Now when the client-side event is raised, the server-side action event handler
will automatically receive the parameter value supplied by the UI element.
UI Element Hierarchy
Internal
Only
Event Handler
RootUIElementContainer
DDIndex
map parameters …
Partner
2
DropDownBox1
Use
index 1
Action get reference
dd
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
z It was previously stated out that a single action event handler could
be dynamically assigned to multiple UI elements.
UI Element Hierarchy
Internal
Only
Event Handler
RootUIElementContainer
CheckBox1
Partner
Which
Check Box ? CheckBox2
Use
Action
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
z Coding steps:
1. Obtain references to all the UI elements that will share the use of the
generic action handler.
2. Map the UI element’s action parameter(s) as normal
3. Additional create a hard-coded action parameter that will identify which
UI element invoked the action handler.
4. The action handler must now have an additional parameter declared in
its interface called (in this case cbName) of type String.
Internal
Only
UI Element Hierarchy
Event Handler
cbName add parameters
RootUIElementContainer
State 4
Partner
checked CheckBox1
CheckBox2
cb1
Use
checked
Action
cb2
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Distinguishing 2 check boxes that both invoke the same action handler
if (firstTime) {
Internal
Only
cb2.mappingOfOnToggle().addSourceMapping("checked","State");
Use
cb1.mappingOfOnToggle().addParameter("cbName",cb1.getId());
cb2.mappingOfOnToggle().addParameter("cbName",cb2.getId());
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
node.
1 Development Objectives
Partner
In this exercise you will dynamically add an independent value node to view controller’s
context.
Use
2 Result
SAP
SAP
Partner
Use
Only
Template Solution:
WD Project: JA310_WD_DynMod
Application: JA310_WD_DynMod
Internal
Only
be created dynamically at runtime, both the context view and the layout view will
remain empty.
4-4 Go to the layout tab of the view controller and delete the UI element called
DefaultTextView as this is not needed.
Partner
4-5 Go to the Implementation tab of view controller Ex9View. At various points during
the coding, you will need to select “Organize Imports” from the right mouse click
Use
menu in the Java editor.
4-6 Locate the wdDoInit() method and enter the coding to create a new value node
called SalesOrders.
SAP
SAP
4-6-1 Get a reference to the metadata of the controller’s root node. Use the
wdContext.getNodeInfo() method.
4-6-2 Using the object returned from getNodeInfo(), create the metadata for a new
Partner
value node by calling its addChild() method. This method requires 11
Use
parameters as follows:
- The node name (String)
- Structure reference (Class).
Internal
Only
- Does the node selection require one element to be selected at all times?
(Boolean)
- Can multiple elements from the node collection be selected? (Boolean)
- Should the value of the lead selection be initialized? (Boolean)
- Does this node refer to a dictionary data type (Object)
- Node supply function (IWDNodeCollectionSupplier)
- Node disposer function (IWDNodeCollectionDisposer)
4-6-3 Using the IWDNodeInfo object returned by the previous call to addChild(),
use the addAttribute() method to create four new attributes. These attributes
have their names and data types as follows:
- OrderNo ddic:com.sap.dictionary.integer
- SalesDate ddic:com.sap.dictionary.date
- SalesRep ddic:com.sap.dictionary.string
- LongText ddic:com.sap.dictionary.string
© SAP AG JA310 10-43
4-6-4 Now that you have created the metadata for a new context node and its
attributes, the next thing to create is an instance of the node itself. This is
done by using the generic context API. Since our new node SalesOrders is
an independent node, its parent is the context root node. Therefore, you need
to call the method wdContext.getChildNode(String, int) to create a new
instance of the SalesOrders context node.
4-6-5 Using the IWDNode object returned by getChildNode(), create a new
element for this node using its generic createElement() method.
4-6-6 Using the generic IWDNodeElement object returned by createElement(), call
the setAttributeValue() method once for each of the four attributes.
Remember that the second parameter to setAttributeValue() is of type
Object, therefore, you must pass any Java primitive values as their
Internal
Only
equivalent object (e.g. you can’t pass an int, but you can pass an Integer())
- OrderNo 100
- SalesDate Today’s date
- SalesRep “Harry Hawk”
- LongText “Printer Supplies”
Partner
4-6-7 Warning, when you use an object of type Date, you must import package
java.sql.Date, not java.util.Date!
Use
By default, Web Dynpro always uses java.sql.Date objects.
4-6-8 Finally add the node element object to the node collection.
4-7 Now you have some data stored in the dynamically defined value node
SAP
SAP
Partner
Use
5 Overview: Developing - Create new UI elements that display the contents of the new
value node
5-1 Locate the method wdDoModifyView(). It is in this method that you will create the
Internal
dynamic UI elements.
5-1-1 Enclose all of the following code within a test for the parameter firstTime
being true.
Only
5-1-2 Obtain a reference to the root UI element container under which all
subsequent UI elements will be defined. This is an object of type
IWDTransparentContainer.
To do this you must use the view.getRootElement() method remembering
that whether you’re getting a reference to an existing UI element, or creating
a new one, the view object always passes back a generic IWDViewElement
object. Thus you have to cast this object to the appropriate type.
5-1-3 Set the root UI element’s layout manager to be Matrix layout. This is done
by calling the createLayout() method, not the setLayout() method that you
might expect. The createLayout() method requires the class of one of the
layout manager interfaces as its parameter. In this case, you will need
IWDMatrixLayout.class.
Internal
Only
from the name of the IWDAttributeInfo object you stored in the previous
step (hint: call its getName() method) plus the text “Label”.
- Set the label’s text property to be the text returned from
Use
IWDAttributeInfo.getName().
- Set the label’s layout data to be MatrixHeadData (hint: use the
createLayout() method – there is no setLayout() method!)
SAP
SAP
Partner
(IWDAttributeInfo.getName()) plus the text “Input” (this will be the name
Use
Only
IWDLabel.
The name of the UI element object should end with the text “Input”.
- Bind the input field UI element you have just created to the attribute info
object derived in step 5-1-4.
- Set the input field’s layout data to be MatrixData.
- Add the input field UI element to the transparent container object derived
in step 5-1-2.
5-1-8 Save your metadata.
5-2 Create a new application called Ex9App belonging to package
com.sap.training.wd.ex9.
5-3 Deploy and run your application.
Internal
Only
Use
IWDNodeInfo rootNodeInfo = wdContext.getNodeInfo();
SAP
SAP
IWDNodeInfo soNodeInfo =
rootNodeInfo.addChild(
"SalesOrders", // Name
Partner
Use
Only
null, // Dictionary reference
null, // Supplier function
null); // Disposer function
Internal
Only
new Date(System.currentTimeMillis()));
soElement.setAttributeValue("SalesRep", "Homer Simpson");
Use
soElement.setAttributeValue("LongText", "Printer Supplies");
SAP
SAP
soNode.addElement(soElement);
//@@end
Partner
Use
}
Internal
Only
public static void wdDoModifyView(
IPrivateEx9View wdThis,
IPrivateEx9View.IContextNode wdContext,
com.sap.tc.webdynpro.progmodel.api.IWDView view,
boolean firstTime)
{
//@@begin wdDoModifyView
Internal
Only
Use
// Get the metadata of the next attribute
IWDAttributeInfo soAttrInfo =
SAP
SAP
(IWDAttributeInfo) iter.next();
Partner
Use
soAttrInfo.getName() + "Label");
Only
// Set the text property to the name of the attribute, change
// the layout data to MatrixHeadData, switch off the vertical
// bar to the left of the label text and connect the label to
// the input field, to be defined next .
label.setText(soAttrInfo.getName());
label.createLayoutData(IWDMatrixHeadData.class);
label.setDesign(WDLabelDesign.LIGHT);
label.setLabelFor(soAttrInfo.getName() + "Input");
Internal
Only
ioField.bindValue(soAttrInfo);
Use
// Add the InputField UI element to the root UI element
// container
rootElement.addChild(ioField);
SAP
SAP
Partner
Use
}
//@@end
Internal
Only
Contents:
z Remote invocation of ABAP functionality
z The creation and management of Adaptive RFC (aRFC)
model objects
z The management of use aRFC Model objects
z The configuration of the SLD and JCo Connections
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
z The JCo layer was later added to give the Java language
access to the RFC layer.
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
ABAP Runtime
Environment
generated by the SAP
Enterprise Connector
Static proxy objects
External Program
RFC Layer
RFC enabled
librfc32.dll
JCo Layer
CPI-C
CPI-C
TCP/IP ABAP
Function
Module
Internal
Only
Partner
Use
design time. This means interface metadata are not available at
runtime.
SAP AG 2004
SAP
SAP
The original implementation of the JCo layer contained functionality to adapt to changes in the interface
Partner
structure, but at that time, no applications required this functionality, so it was not implemented in the
Use
Only
Internal
Only
Use
SAP AG 2004
SAP
SAP
At the lowest technical level, a remote function call to an SAP system sends and receives a byte stream.
Partner
The proxy objects built by the Java Enterprise Connector use a static offset and length lookup to parse
Use
the byte stream and obtain the field level information. Therefore, if a new field is added to the interface
structure, the positions of all subsequent fields are shunted down the byte stream. The Java Enterprise
Connector’s static offset and length lookup system can not react on such changes!
The JCo layer itself contains the functionality to access any field in the RFC interface; however, the
Internal
Java Enterprise Connector makes no use of this functionality, and can therefore not react to structural
interface changes at runtime.
Only
jRFC Layer
RFC Layer
RFC enabled
JCo Layer
CPI-C
CPI-C
TCP/IP ABAP
Function
Module
Internal
Only
Partner
Use
fully implement, the functionality found in the JCo layer.
SAP AG 2004
SAP
SAP
Partner
Every time an RFC enabled function module is called in an SAP system, the metadata describing its
Use
interface is checked.
If the interface has changed since the last invocation, the new metadata data is obtained from the SAP
system. The application program should then check the dictionary for changes and react appropriately.
The aRFC layer will automatically update the dictionary with any metadata changes, but it is up to you
Internal
Only
Internal
Only
Value Sets
Partner
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
Use
SAP AG 2004
SAP
SAP
The aRFC layer can adapt to the addition of new fields in an existing interface structure.
Partner
For instance, any function modules delivered by SAP that make use of .APPEND structures can be
Use
extended by the customer. It is this type of interface change to which the adaptive RFC layer can react,
and the metadata definition will be updated at runtime.
The Web Dynpro Application must check for metadata changes!
If you want your application to be able to respond to the new metadata supplied by the aRFC layer at
Internal
runtime, then you must write your application to check for changes. There’s no magic here!
Only
Internal
Only
0..1 Changing * * *
Parameters
DDIC
Structure
*
Partner
*
Tables
*
Use
0..1
Exceptions
SAP AG 2004
SAP
SAP
Partner
y Import parameters
Use
Scalar or structured parameters used only on the inbound side of the interface having a cardinality of
0..1.
y Export parameters
Scalar or structured parameters used only on the outbound side of the interface having a cardinality
Internal
of 0..1.
y Changing Parameters
Only
Bi-directional scalar or structured parameters having a cardinality of 0..1.
RFC enabled function modules tend not to use CHANGING parameters.
y Tables
Bi-directional structured parameters having a cardinality of 0..n.
y Exceptions
Text labels used to identify an unexpected termination of processing within the function module.
Exceptions can only be invoked by means of the ABAP statement RAISE.
RFC enabled function modules should avoid the use the RAISE statement! The reason for this will
be explained later.
Internal
Only
4) Be remote enabled
5) Run to completion without the need for any secondary user interaction
6) Handle all errors gracefully
7) Not cause an ABAP session change
Partner
Use
Criteria to which a customer developed remote function module
must adhere
SAP AG 2004
SAP
SAP
Partner
During a Web Dynpro implementation that uses an SAP system as its business back-end, it is likely that
Use
your Web Dynpro program will need to call some custom written ABAP function modules. In this
situation, it is essential that your function modules comply with criteria 4 to 7 above!
Further clarification for custom written remote modules:
y Point 4: Don’t forget to switch on the Remote Enabled flag!
Internal
y Point 5: If any attempt is made to invoke a SAPGUI screen of any sort, the RFC connection will be
terminated immediately!
y Point 6: A remote module must run to completion irrespective of any errors that occur. This means
Only
that when control is passed back to Web Dynpro, the data in the interface will accurately reflect the
success or failure of execution.
The use of the ABAP statement RAISE must be avoided because it will terminate the function module
immediately, leaving the interface in a potentially undefined state.
y Point 7: Important: Do not use any ABAP statement that would cause the current logical unit of
work (LUW) within the SAP User Roll Area to terminate! This has an impact on the RFC connection
and will interfere with your ability to manage transactional data in the SAP system.
z The aRFC layer can call any remote enabled ABAP function
module whether it be a standard BAPI delivered by SAP, or a
customer written remote function module.
z Therefore, the subsequent slides will refer to generic Remote
Function Modules (RFM’s) rather than only BAPI’s.
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
The skills listed below should be considered the minimum level of SAP
competence required by all Web Dynpro developers wishing to use the
aRFC interface.
Beyond this, extra skills related to the actual SAP application area within
which you are working may also need to be acquired.
Internal
Only
structure’s metadata.
z Use transaction SE16 (Data Browser) to display the contents of a
database table.
Use
SAP AG 2004
SAP
SAP
Whilst it is not necessary for a Java Web Dynpro programmer to be able to program in ABAP, it is very
Partner
important that the interface presented by an ABAP function module is understood. Within Web Dynpro,
Use
the different parameter types found in the function module’s interface will be represented as different
model objects. In order to understand the generated objects, you must understand the interface of the
underlying ABAP function module.
If you are a Java developer with no prior experience of an SAP system, then in order to have a full
Internal
understanding of the interface with which you are working, you should gain the above listed skills in an
SAP system (these skills are very basic and can be acquired in a matter of hours).
Only
Internal
Only
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Select Import
Adaptive RFC Model
and press Next.
Internal
Only
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Enter a model
package name.
Internal
Only
Partner
z Important: Each model object must live in its own Java package!
Use
SAP AG 2004
SAP
SAP
Please observe the SAP naming convention for model objects: {nm} = {m}Model.
Partner
Where {nm} is the actual model object name and {m} is the desired model name
Use
Always ensure that you create an individual Java package per model object! The package name should
conform to a pattern such as {pkg1}.{pkg2}.{pkg3}.models.{m}. See the SAP recommended
naming convention listed in the Appendix.
Internal
If you have two model objects that share the same data structure (e.g. the structure BAPIRET2 that
defines the RETURN parameter of many BAPI’s), then placing the model objects in different packages
Only
avoids any runtime ambiguity that could occur.
Internal
Only
Press Next.
Use
time the model object is created.
SAP AG 2004
SAP
SAP
Logical system names can be any meaningful names you desire. However, please avoid creating names
Partner
that contain the SAP system name, as this will create confusion once the application is transported out
Use
E.G.: If you wish to call some HR Payroll remote modules in the SAP system called DEV, then
HR_PAYROLL_DATA and HR_PAYROLL_METADATA are much better logical system names than
Internal
Only
Internal
Only
on the Single
Server tab.
Use
SAP AG 2004
SAP
SAP
As for the SAP GUI for Windows, the information displayed by the drop down list on the Load
Partner
Balancing tab is obtained from the saplogon.ini file, which is located in the Windows directory.
Use
Internal
Only
Enter a wildcard
search for the
remote module
name(s) and
press search
Each selected
remote module
Internal
Only
will be imported
into the current
model object
Partner
Use
SAP AG 2004
SAP
SAP
Partner
This is a deliberate design decision because the average SAP contains around 9,500 remote callable
Use
function modules. It would be highly inefficient to present a list of all such remote modules, from which
only a few will actually be required!
You will only see a list of function modules after a search criterion has been entered and the Search
button has been pressed.
Internal
Only
Internal
Only
the changes.
Partner
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
The aRFC
model
wizard
creates
two sets
of objects
Internal
Only
Use
RFM interfaces are constructed.
z These classes are built from the
z Simple Types
metadata found in the model’s
z Structures
SAP AG 2004
dictionary.
SAP
SAP
Partner
A dedicated dictionary is created for each model object. Each dictionary contains a set of Simple Types
Use
These are the dictionary entities that describe all the structured interface parameters. Every Structure
listed here is built from the Simple Types shown in the same dictionary.
Model Class Hierarchy
Only
A hierarchy of model classes is constructed to represent the entire interface of each RFM in the model
object. For each remote function module {rfm}, an {rfm}_Input and an {rfm}_Ouput class will
always be created.
The additional classes are named according to the structure name found in the ABAP data dictionary,
not the parameter name in the RFM’s interface. For instance, if the RFM has an EXPORTING parameter
called RETURN that is based on the dictionary structure BAPIRET2, then you will see the name
BAPIRET2 listed and not RETURN.
Internal
Only
Partner
Use
the RFM’s interface, and uses the same name as the corresponding
ABAP dictionary type.
SAP AG 2004
SAP
SAP
Simple Types
Partner
Simple Types for aRFC interface fields are defined using Web Dynpro Built-In Types (date, string,
Use
integer etc). These are not the same as the namesake Java classes!
Internal
Only
Internal
Only
Partner
Use
z They have the same name as the corresponding structure in the
ABAP dictionary.
SAP AG 2004
SAP
SAP
Structures
Partner
The structured classes seen in the model hierarchy are defined using the structured data types defined in
Use
Only
Internal
Only
Use
Output
Structure
SAP AG 2004
SAP
SAP
Partner
All aRFC model classes have an RFC part type associated with them; this describes the function played
Use
Only
Internal
Only
Use
Only structured parameters are
shown in the model class hierarchy.
SAP AG 2004
SAP
SAP
Scalar parameters
Partner
A scalar parameter is any value that can be described as a single field. These are not shown directly in
Use
the model class hierarchy, but can be displayed by double clicking on the model class name, and then
selecting the Properties tab from the editor window.
Internal
Only
Internal
Only
Use
SAP AG 2004
SAP
SAP
Partner
All RFC model classes are arranged in a hierarchical structure that, taken together, represents the entire
Use
The controlling class in this hierarchy is always {rfm}_Input. This class must be instantiated first,
and it is the only RFC model class to possess an execute() method. Once the method
Internal
Only
All structures used to type IMPORTING, EXPORTING, CHANGING or TABLES parameters to {rfm}
will be represented by the classes of RFC type structure.
E.G. Destination_From
Occurs
twice! Any parameter that occurs under
Internal
Only
E.G. Flight_List
Use
SAP AG 2004
SAP
SAP
Bi-directional parameters
Partner
Important: Due to the fact that CHANGING and TABLES parameters of an RFM are bi-directional, it is
Use
necessary to preserve an “input” and “output” image of these parameters. This means that you will see
the same parameters listed under both the {rfm}_Input and {rfm}_Output classes. At runtime,
these classes become separate instances that hold the “before execution” and “after execution” images
of the parameter values.
Internal
This important fact that must be understood because it has a significant impact when binding context
Only
model nodes to model objects.
Instance
of z Every time the
{rfm}_Input.execute() method is
Internal
Only
Use
RFM requires no input parameters!
SAP AG 2004
SAP
SAP
Partner
If an RFM requires input parameters, these must be supplied to the instance of class {rfm}_Input.
Use
Once the RFM has executed, and instance of {rfm}_Output will be available as a child of
Internal
{rfm}_Input.
Only
Internal
Only
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
Therefore, all deployed applications using the same model object pointing to the same JCo destination
Use
Only
Therefore, a model object should contain no more functionality than is required by the consuming
component.
Since a component should be written to implement a discrete business task, the models it consumes
should therefore supply distinct subsets of functionality, grouped together by business task.
Answer:
A model object should contain
those RFMs that supply the
functionality for either a discrete
business task, or some atomic
subset of the business task.
In the example on the right, the model
ServiceOrderModel has been
Internal
Only
Use
SAP AG 2004
SAP
SAP
Having one RFM per model is inefficient from a connection management point of view.
Partner
Having all your RFMs in one big model object is inefficient from a reuse point of view.
Use
Internal
Only
Internal
Only
Use
Perspective.
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
4. Any application DC
wishing to use a model
object should declare
the use of the Models
DC.
Internal
Only
Use
SAP AG 2004
SAP
SAP
It is most important, that once you have built your DC’s, you should perform a DC Build. This is done
Partner
by right mouse clicking on the DC name itself, then selecting Development Component and then Build
Use
Only
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
Use
The actual runtime data is stored in the model objects!
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
Partner
Use
Binding from the right mouse click pop-up menu of the context
model node.
SAP AG 2004
SAP
SAP
The Data Modeler Tool provides a wizard to create not only the binding between the controller context
Partner
and the model object, but also most of the source code necessary to execute the model and handle
Use
possible errors.
Internal
Only
Context Context
wdDoInit()
Root Node Root Node
ng
Bindi
ent
lem
ing
Context Mapping UI E
ind
onAction{act}()
Internal
Only
lB
Model
de
Usage
Mo
Model callRFM()
Object
Partner
Use
and data binding.
SAP AG 2004
SAP
SAP
Data passes from the model object to the screen using this chain of connections:
Partner
y The context of the component controller is bound to the model object.
Use
Only
Context Context
wdDoInit()
Root Root
xt
Node
par e conte Node
Pr e
ing
ind
onAction{act}()
Internal
Only
lB
Model
de
Usage
Mo
Model callRFM()
Object
Partner
Use
corresponding model node.
SAP AG 2004
SAP
SAP
Preparing the controllers context includes the creation of a model object and the binding of this instance
Partner
to a model node in the context.
Use
For each non-scalar import parameter of the RFM, it is necessary to create a related object and add this
object to the model instance. The object has to be an instance of the generated model class, that has the
name of the import parameters structure type.
Internal
Only
Context Context
wdDoInit()
Root Node Root Node
onAction{act}()
Internal
Only
Model
Usage
Model callRFM()
Object
Partner
2. The client side event (pushing the button) triggers the server side
Use
event handler method onAction{act}().
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Context Context
wdDoInit()
Root Node Root Node
onAction{act}()
Internal
Only
Model
Usage
Model callRFM()
Object
Partner
Use
view controller calls a method in the component controller to invoke
the RFM.
SAP AG 2004
SAP
SAP
To access a method of the component controller from within a method of the view controller, the self
Partner
reference wdThis is used.
Use
E.G. To call the method {nm} in the component controller of component {nc}, the following
expression is used: wdThis.wdGet{nc}Controller.{nm}()
Internal
Only
Context Context
wdDoInit()
Root Node Root Node
2)
I
nv utpu
ali t
o
onAction{act}()
Internal
Only
da no
Model
te de
Usage
co
nt
ex
Model callRFM()
t
Object
Partner
1) Call RFM
Use
functionality, and then invalidates the corresponding output node
in the context.
SAP AG 2004
SAP
SAP
Invalidating the models output nodes is necessary to have access to the actual model data.
Partner
Use
Internal
Only
Context Context
wdDoInit()
Root Node Root Node
ng
Bi ndi
ent
I Elem
U
Context Mapping
onAction{act}()
Internal
Only
Model
Usage
Model callRFM()
Object
Partner
Use
returned by the RFM call is now visible on the screen.
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
}
...
//@@begin others
Use
IWDMessageManager msgMgr;
Bapi_Flight_Getlist_Input bapiInput;
//@@end
SAP AG 2004
SAP
SAP
This coding will normally be defined in the wdDoInit() method of a custom controller (typically the
Partner
component controller).
Use
Once the above coding has been executed, the BAPI_FLIGHT_GETLIST function module will be
able to receive input values in the structured parameters DESTINATION_TO and
DESTINATION_FROM.
Internal
It is useful to create the executable model object as a class variable. That way it can be accessed by any
method in the custom controller.
It is also useful to create a class variable to refer to the component’s message manager.
Only
Internal
Only
}
}
Partner
Use
SAP AG 2004
SAP
SAP
The call to any particular RFM should always be placed within a dedicated method in the custom
Partner
controller. Using the wizard in the Data Modeller Tool, this method is created automatically including
Use
Once the invalidate() method has run against the model object’s Output node, the data returned
by the RFM will be available in the context.
Only
Generic code: Create a model object instance, bind it to a context model node
// Create a new instance of the Bapi_Flight_Getlist_Input
// model object
{rfcm)_Input bapiInput = new {rfcm}_Input();
// If {rfcm} requires any structured parameters, these
// instances must be created and added to the instance of
// the {rfcm}_Input object
{rfcmin} inputStructure = new {rfcmin}();
bapiInput.set{rfcmin}(inputStructure);
// Bind the model object instance to context model node
Internal
Only
wdContext.node{rfcmin}_Input().bind(bapiInput);
Partner
Use
SAP AG 2004
SAP
SAP
In its generic form, the coding to use a model object requires three main steps, the second of which is
Partner
optional, depending on the individual requirements of the RFM being called.
Use
y Create an instance of the RFM class. By default, the class will be called {rfcm}_Input.
y Create any structured parameters that the RFM may require and add them to the instance of the
{rfcmin}_Input class. This step is dependent upon the individual requires of the RFM you are
using.
Internal
Only
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Importing the software catalog is the first step in configuring technical systems in the SLD. The software
Partner
catalog contains technical information to all possible SAP products and software components.
Use
To check, if the technical information for the type of system you want to connect to (to obtain model
data) has already been imported, open the software catalog of your SLD:
http://<host>:<port>/sld → Link Software Catalog
If the SAP product or software component is not displayed, you have to import the newest software
Internal
Only
For a standard J2EE Installation, the software catalog is provided by a .zip file, which is located at
<root>/usr/sap/<J2EE System Name>/SYS/global/sld/model
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Before any JCo connection can be defined, a new technical system has to be defined in the SLD. A
technical system is a logical object, that contains all metadata to a certain SAP system, like the system
Partner
Use
ID (SID), the names of all application servers, the message server name, logon groups and so on.
To define a new technical system, open the following page:
http://<host>:<port>/sld → Link Technical Landscape
Internal
Only
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Proceed as follows:
Partner
y On the first screen press New Technical System.
Use
y Press Next.
Only
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Proceed as follows:
Partner
y Enter the message server host, application server host, the instance number, the message server port
Use
y Press Next.
y On the next screen you can add the name of all application server hosts (and their instance numbers)
belonging to the same SAP system. Press Next.
Only
y Now enter all clients, you want to use with the JCo connections. At least one client has to be defined.
Press Next.
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Proceed as follows:
Partner
y Select the technical product, describing your SAP system. This is, where the software catalog
Use
Result: A new Technical System has been defined, which can be used to define JCo connections to the
underlying SAP system.
Only
Internal
Only
Partner
Obtain metadata
at runtime
Use
SAP AG 2004
SAP
SAP
At the time a model object is created, the logical system names do not yet need to exist in the J2EE
Partner
engine. The Web Dynpro application can be fully built and deployed to the J2EE engine before it
Use
Only
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
The System Landscape Directory (SLD) Server must be started & configured.
Partner
Start the Web Dynpro Content Administrator application by entering the URL
Use
http://<host>:<port>/webdynpro/welcome → Link Content Administrator
You will need to log on with a user id that has administrative authority.
Internal
Only
Internal
Only
Destinations.
Partner
Use
Click Create against the JCo
destination that you are going to set up.
SAP AG 2004
SAP
SAP
Partner
y Defining the model object to use a given pair of logical destinations
Use
y Do not hard code the SAP system name
y Use a name that describes the type business information being used.
All JCo destinations for all deployed applications will be listed in this screen.
Only
The red icon indicates that the JCo destination is required by an application, but has not yet been
defined.
Click on the link named Create in order to set up the JCo Destination.
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Step 1:
Partner
y Enter the client of the system, the JCo connection is pointing to
Use
y Press Next.
Maximum Pool Size: The parameter Pool Size is used to specify how many connections should be left
open for the current user, even if they are not being used actively. A pooled RFC connection is allocated
much faster than a new connection, therefore, increasing the pool size will optimize the time needed to
Internal
get a new connection. On the other hand, if a connection is pooled, it is not available for other users.
Maximum Connections: Maximum amount of connections per user. This needs to be determined for each
Application Data destination (also called logical system).
Only
Connection Timeout: Defines how long the pool waits (in seconds) before a destination, which is in the
range between 1 and the maximum pool size, is closed by the pool. This allows closing pooled
connections after a certain amount of time, if the user is no longer active. A typical value here is 10 - 30
seconds.
Maximum Wait Time: Defines how long you can wait (in seconds) before you get an exception after
trying to get a destination although the maximum destinations are open. In a high user load scenario, it
makes sense to increase this number appropriately (20-60), in low user load scenarios, this number can
typically be reduced to a very low number (1-5 seconds).
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Step 2:
Partner
y Select which J2EE cluster you wish the JCo destination to be assigned.
Use
y Press Next.
Step 3:
y Select the connection type – Application Data or Dictionary Meta Data.
When Application Data is selected, you can choose between direct connection to a distinct
Internal
Only
Internal
Only
If Application Server
Partner
Use
SAP AG 2004
SAP
SAP
Partner
y You may only select Servers and / or Logon Groups from the drop down list that have first been
Use
group defined! If this has not been done, then you will be unable to proceed beyond this screen.
If your SAP has no logon groups, then use transaction SMLG in the SAP system to create one.
Only
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
If you select a connection type of Application Data, then when you get to the Security screen, you will
Use
y User Mapping (Requires the use of the User Mapping Engine in the J2EE engine)
For development and testing scenarios, it is acceptable to use the User/Password authentication
method. However, for productive use, you should always choose a method that allows user specific
Only
authorisations to be employed within SAP. This will help provide an application level audit trail of
user activity.
If you select User/Password for you productive system, then all users using this JCo connection will
appear to be the same user within SAP. Thus, you will loose any audit trail capability.
Step 5 (Dictionary Meta Data):
If you select a connection type of Dictionary Metadata, then when you get to the Security screen, you
will only be able to use a named user id and password for connection to the SAP system. This is because
no audit trail is required for the transfer of metadata. Therefore, the same user id (SAP user is of type
SYSTEM) can be used irrespective of the identity of the end user.
Press Next.
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Step 6:
Partner
y Check your configuration data on the Summary screen.
Use
y Press Finish.
The icon next to the JCo destination now turns green.
Finally, press the Test button to ensure that your JCO connection works. You must scroll to the bottom
of the browser window to see the success/failure message.
Internal
Important: You must repeat this process for the second JCo destination!
Once both JCo destinations have been successfully created, you are ready to run your Web Dynpro
Only
application.
Internal
Only
Partner
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
If several different Web Dynpro applications all use the same model object
pointing to the same JCo destination, then after deployment, there will only be
one copy of that model object’s metadata in the J2EE engine’s cache.
The architecture of this cache in the NetWeaver ’04 release is such that it is not
currently possible to determine which application uses which model object in the
optimized cache.
Internal
Only
Therefore, if the aRFC layer updates the metadata of a deployed model object, it
is necessary to restart the J2EE engine to flush this cache, and make the new
interface metadata available to the Web Dynpro application.
Partner
Use
SAP AG 2004
SAP
SAP
Partner
Use
Internal
Only
Internal
Only
1 Development Objectives
This exercise has the following objectives:
Partner
Use
- Use the functionality defined in one development component within another
development component.
- Use the aRFC model object to call a function module in an SAP system and then display
SAP
SAP
the results.
The aRFC model object will be created in a development component (DC) called
“models”. This DC will expose the model object functionality via its public part.
Partner
Use
There will then be a second web Dynpro DC called “components” that makes use of the
models DC. Thus, we can separate model objects from the Web Dynpro components that
use them. This improves the overall application architecture, and helps reduce the Java
compile time.
Internal
Only
Internal
Only
Template Solution:
Development Component containing Model: JA310_Models
Development Component containing WD Application: JA310_Components
WD Project: Ex10Comp
Partner
Application: Ex10App
Use
3 Prerequisites
You have launched the SAP NetWeaver Developer Studio.
You have selected the Web Dynpro perspective.
SAP
SAP
4 Overview: Developing
4-1 Create a new Web Dynpro Development Component called models. Select File →
New → Development Component Project, then select Local Development →
Partner
Use
Only
are created. DCs of different languages will not interact with each other correctly.
4-4 Open the models DC hierarchy, and select Create Model from the right mouse click
menu under Web Dynpro → Models.
Select Import Adaptive RFC Model and then press Next.
Remember that the model name should end in the word Model, and that each model
object must live in its own package. In the screen, enter FlightListModel as the model
name, and com.sap.training.models.flightlist as the model package name.
The logical system names (JCo Destinations) entered here do not yet need to exist in
the J2EE engine. Remember that the logical system names should not contain the
name of the system from which you are obtaining the data. Rather, they should
describe the type of data being obtained.
The Logical Dictionary name should be allowed to default to the same name as the
model object.
Internal
Only
(which are each separate JAR files) will not be constructed properly.
Firstly, click on the entire models DC, and select Rebuild Project. This will only take
a few seconds.
Use
Now right mouse click again on the DC name and select Build from the Development
Component side menu.
Since development components can declare the use of other development
components, it is possible that a set of dependencies can exist between these DCs.
SAP
SAP
This particular case, the models has no dependencies on any other DCs, so this next
screen only shows a list of one DC. Select OK.
4-8 Now open the following branch in the components DC: DC MetaData → DC
Partner
Definition → Used DCs.
Use
At the moment, the components DC only requires the use of standard Web Dynpro
DCs. You must add to this list and declare that the models DC is also a Used DC.
Right mouse click on Used DCs and select Add Used DC. Expand the branch
Internal
Only
4-9 In the components DC, open the Web Dynpro branch of the hierarchy, and create a
new Web Dynpro Component called FlightListComp. Use a package name of
com.sap.training.flightlist and don’t forget to remove the characters Comp from the
view name.
4-10 In the Used Models node of component FlightList, add the usage of model
FlightListModel.
Internal
Only
In this case, we are going to use the two scalar parameters Airline and Max_Rows,
and the two structured parameters Destination_To and Destination_From.
Since the parameters Date_Range, Extension_In, Extension_Out, Flight_List and
Return are TABLES parameters, they will appear on both the input and output sides
of the interface. We will not be sending any data into the function module via these
Partner
tables, so they can be omitted from the input side of the interface.
However, Flight_List and Return have to be selected at the output side, because we
want to display the data the BAPI sends back.
Use
4-12 The previous step has made the information in the model object available to the
component controller. Now we need to make the data available to the view
controller.
SAP
SAP
This is done by creating another data link starting at the view controller and going
across to the component controller.
As in the creation of the previous data link, you will need to drag the model node
from the component controller context across to the view controller context.
Partner
Use
Select all the nodes in the context hierarchy and then click OK and then Finish.
4-13 Now that the model data has been mapped all the way through to the view controller,
we can start building the view’s user interface.
Double click on FlightListView under Web Dynpro Components → FlightListComp
Internal
→ Views.
Delete the default TextView UI element.
Only
4-14 Select the RootUIElementContainer and change its layout property to MatrixLayout.
4-15 In the Outline view, right mouse click on RootUIElementContainer and select Insert
Child. Add a Tray UI element with the name ParentTray and change the text
property of its child Caption UI element to Input Parameters.
If you find that your Tray UI element is called something like Tray0 or Tray1, then
you can rename it by changing the value of its id property.
4-16 Select the ParentTray UI element from the Outline view and choose Apply Template
from the right mouse click menu. Choose the Form template and press Next.
Select Max_Rows and Airline from the Template Wizard window and press Finish.
4-17 You now need to insert two further Group UI elements as the children of ParentTray.
Select the ParentTray UI element in the Outline view and choose Insert Child. Create
two child Group UI elements called ChildGroupTo and ChildGroupFrom.
Internal
Only
4-23 The last step is to create a table in which the BAPI output results will be displayed.
Select the RootUIElementContainer, and select Apply Template from the right
mouse-click menu.
Use
This time, select a Table template and press next.
Under the Output context node, there will be a child node called FlightList. Select
this check box, and all the child attribute checkboxes will be selected automatically.
SAP
Press Finish and press the Save Metadata button on the toolbar.
SAP
4-24 Now we need to add some coding into the component controller. Double click on the
Component Controller node underneath FlightListComp in the Web Dynpro
Explorer.
Partner
Use
4-26 Now locate method wdDoInit() and assign the message manager variable to the
component’s message manager instance, and assign to the bapiInput object a new
Only
instance of the BAPI class.
4-27 Now create an instance of each of the structure input parameters DESTINATION_TO
and DESTINATION_FROM. The class that needs to be instantiated can be found by
switching to the Context tab, selecting the corresponding model node, and then
looking at the value of the ModelClass property. In this case, the class is Bapisfldst.
4-28 Once these two parameter instances have been created, they must be added as
structured parameters to the main bapiInput object.
4-29 The last step for method wdDoInit() is to bind the BAPI input object to the
corresponding model node in the component controller’s context.
Internal
Only
dependency exists between DC components and DC models. Since the public part of
DC models has not been changed, it is not necessary to rebuild this DC.
Therefore, leave the check box against models unchecked.
Use
Press OK.
4-35 Since the components DC is dependent upon the models DC, it is necessary to deploy
the models DC first. Select the root node of the models DC from the Web Dynpro
SAP
SAP
Explorer window and choose Deploy from the right mouse-click menu.
If this is the first time you have deployed anything to your J2EE server since starting
the NetWeaver Developer Studio, then you will be asked for the SDM password. The
default value is sdm.
Partner
Use
4-36 Now choose FlightListApp from the applications menu, and select Deploy new
archive and run from the right mouse-click menu.
If you have forgotten to create the two JCo destinations FlightList_Data and
Internal
FlightList_Metadata, then when you run the application, you will get a Java stack
trace. This is due to the fact that the J2EE engine is attempting to use a pair of JCo
destinations that have not yet been configured!
Only
Internal
Only
Partner
Use
SAP
SAP
Partner
Use
Internal
Only
4 Overview: Developing
Internal
Only
Press Next.
Use
SAP
SAP
Partner
Use
Only
Internal
Only
Use
in its own package. In the screen, enter
FlightListModel as the model name, and
com.sap.training.models.flightlist as the model
package name.
SAP
SAP
4-5 Specify the name of the SAP system you wish to connect to.
Partner
Use
Only
BAPI_FLIGHT_GETLIST and press Next.
The Model wizard will now extract the details of
the function module’s interface and present you
with a log file.
Press Finish.
Internal
Only
4-6 All that is necessary to complete the models DC is to add the model object
FlightListModel to the DC’s public part.
Partner
Use
Since this is the very first public part defined for
this DC, we must specify the name of the public
part to which this model object will be added.
Enter a public part name of FlightListModel and
SAP
SAP
press Finish.
Partner
Use
Now that this has been done, you will see the
FlightListModel listed as an Entity belonging to the
public part called FlightListModel.
Internal
Only
Internal
Only
Use
4-8 You must add the models DC to the list of used DC
SAP
SAP
Partner
At the moment, the components DC only requires
Use
Only
Press Finish.
Internal
Only
4-9 In the components DC, open the Web Dynpro branch of the hierarchy, and create a new
Web Dynpro Component called FlightListComp.
Use
SAP
SAP
Partner
Use
4-10 In the Used Models node of component FlightList, add the usage of model
Internal
FlightListModel.
Only
add a used model to component FlightListComp,
then one of the following problems could exist:
You have not exposed the model object
FlightListModel correctly through a public part
of DC models.
You have forgotten to build the public part of
DC models.
DC components does not have a correct usage
declaration for DC models.
Internal
Only
Use
Max_Rows, and the two structured parameters
Destination_To and Destination_From from the
input side.
SAP
SAP
Partner
Use
4-12 The previous step has made the information in the model object available to the
Only
component controller. Now we need to make the data available to the view controller.
Internal
Only
Partner
Use
SAP
SAP
Partner
Use
4-21 Next, select the Actions tab from the view controller editor and create a new Action.
Only
Press Finish.
Internal
Only
Use
4-25 Define the static variables bapiInput and msgMgr.
SAP
SAP
//@@begin others
Bapi_Flight_Getlist_Input bapiInput;
IWDMessageManager msgMgr;
//@@end
Partner
Use
Internal
4-26 Assign the message manager variable to the component’s message manager instance,
and assign to the bapiInput object a new instance of the BAPI class.
Only
public void wdDoInit() {
//@@begin wdDoInit()
msgMgr = wdComponentAPI.getMessageManager();
bapiInput = new Bapi_Flight_Getlist_Input();
//@@end wdDoInit()
//@@begin wdDoInit()
. . .
Bapisfldst destTo = new Bapisfldst();
Internal
Only
bapiInput.setDestination_To(destTo);
bapiInput.setDestination_From(destFrom);
Partner
wdContext.nodeBapi_Flight_Getlist_Input().bind(bapiInput);
Use
//@@end wdDoInit()
SAP
SAP
Partner
Use
Internal
Only
//@@begin callBAPI()
try {
bapiInput.execute();
wdContext.nodeOutput().invalidate();
}
catch(Exception e) {
wdContext.nodeReturn().invalidate();
Internal
Only
if (msgText.length()==0) {
msgMgr.raiseException("BAPI call failed", false);
Use
} else {
msgMgr.raiseException(msgText, false);
}
}
SAP
SAP
//@@end
}
Partner
Use
//@@begin onActionSearch(ServerEvent)
Only
wdThis.wdGetFlightListCompController().callBAPI();
//@@end
Contents:
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
required.
z Each placeholder represents the name of a declared metadata
entity
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Development Entities
{a} Application
{act} Action
{c} Component
{cc} Custom Controller
{dc} Development Component
{m} Model
{mo} Model object (referred to by a model node)
{pi} Inbound plug
Outbound plug
Internal
Only
{po}
{pr} Project
{rfcm} RFC module name (defined in ABAP in a remote SAP system)
{rfcmin} Any inbound, structured parameter to an RFC module
{rfcmout} Any outbound, structured parameter to an RFC module
{siv} Standalone component interface view
Partner
Use
{vs} Viewset
{w} Window
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Context Entities
{ca} Any context attribute
{chn} Any context child node
{cn} Any context node
{ctx} Context name; always the same name as the controller to which it belongs
{mn} Model node
{ma} Model attribute
{rn} Recursive node
{vn} Value node
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Use
{vnd} The Java vendor name formed from reversing the order of the first parts of the
package names. Using the example given for the {pkgn} placeholder above,
the vendor could be formed from reversing the order of the first two parts of
package name to give {pkg2}.{pkg1} = sap.com.
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
application.
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
The usage instance name {nu} should therefore consist of the usage purpose {p}
followed either by the desired component name {c} if a component is being used, or the
standalone interface name {si}.
Partner
Use
followed by the suffix Cust.
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
being left, not the reason for which the target view is being entered!
Use
The project name {np} should describe the category of the business processes it
contains.
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
A window {w} represents an arrangement of one of more views that will form the visual
interface for controller {nctl}. The collective name for the set of views making up the user
interface is a “view assembly”.
A window contains one or more views, and implements a component interface view.
There is a 1:1 relationship between a window and a component interface view. From a
Partner
programming point of view, you gain access to the current view assembly through the
window, but from a consumer’s point of view (I.E. someone using the component), the
view assembly is accessed through the component interface view.
Use
Since window {w} does not relate to any developer modifiable unit of Java coding, it is
unnecessary to use any particular suffix in its name.
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Classes SampleComp
SampleComp ModelCust
ModelCust MainView
MainView
wdThis wdThis wdThis
wdThis
Generated Private Controller Interfaces
Private IPrivate-
IPrivate- IPrivate-
IPrivate- IPrivate-
IPrivate-
SampleComp
SampleComp ModelCust
ModelCust MainView
MainView
Interfaces
wdGetAPI() wdGetAPI() wdGetAPI()
wdGetAPI()
Generic Controller
Interfaces
IWDController
Internal
Only
IWDController
Generic IWDComponent IWDViewController
IWDViewController
IWDComponent
Interfaces getComponent()
IWDWindow-
IWDWindow-
IWDMessage IWDComponent- IWDWindow-
IWDWindow-
IWDWindow-
Service IWDMessage
Manager
IWDComponent-
Info
Manager
IWDWindow-
Manager
Manager
Manager
Manager
Manager Info Manager
Interfaces
Use
implements
Interface Class extends
Interface
other relation
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
IWDController
IWDAction getAction(String name)
IWDComponent getComponent()
IWDContext getContext()
IWDControllerInfo getControllerInfo();
String getText(String key)
String getText(String key,
Object parameters[])
extends String getName() extends
String getPackageName()
String getQualifiedName()
Internal
Only
IWDComponent IWDViewController
IWDMessageManager getMessageManager() IWDAbstractViewInfo getViewInfo()
IWDValidationCheck getValidationCheck() void firePlug(...)
IWDComponentInfo getComponentInfo() void requestFocus(IWDAction action)
Partner
Use
void removeEventHandler(...)
boolean isApplicationRoot()
IWDApplication getApplication()
SAP
SAP
SAP AG 2004
Partner
Use
IWDController
All controllers created by the Web Dynpro IDE implement this interface.
IWDComponent
This interface extends IWDController and is implemented by all Web Dynpro components .
Internal
IWDViewController
All view controllers created by the Web Dynpro IDE implement this interface. This interface extends
IWDController.
Only
Classes SampleComp
SampleComp ModelCust
ModelCust MainView
MainView
wdThis wdThis wdThis
wdThis
Generated Private Controller Interfaces
Private IPrivate-
IPrivate- IPrivate-
IPrivate- IPrivate-
IPrivate-
SampleComp
SampleComp ModelCust
ModelCust MainView
Interfaces MainView
wdGetAPI() wdGetAPI() wdGetAPI()
wdGetAPI()
Generic Controller
Interfaces
IWDController
Internal
Only
IWDController
Generic IWDViewController
IWDComponent
IWDComponent IWDViewController
Interfaces getComponent()
IWDWindow-
IWDWindow-
IWDMessage IWDComponent- IWDWindow-
IWDWindow-
IWDWindow-
Service IWDMessage
Manager
IWDComponent-
Info
Manager
IWDWindow-
Manager
Manager
Manager
Manager
Manager Info Manager
Interfaces
Use
implements
Interface Class extends
Interface
other relation
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Classes SampleComp
SampleComp ModelCust
ModelCust MainView
MainView
wdComponentAPI
wdThis wdThis wdThis
wdThis
PI
Generated Private Controller Interfaces
I
A
AP
nt
nt
Private
ne
IPrivate-
IPrivate- IPrivate-
IPrivate- e IPrivate-
IPrivate-
on
po
SampleComp
SampleComp ModelCust
p
ModelCust MainView
MainView
Interfaces m
m
wdGetAPI() Co wdGetAPI()
Co
wdGetAPI()
wd
wdGetAPI()
wd
Generic Controller
Interfaces
IWDController
Internal
Only
IWDController
Generic IWDViewController
IWDViewController
IWDComponent
IWDComponent
Interfaces getComponent()
IWDWindow-
IWDWindow-
IWDMessage IWDComponent- IWDWindow-
IWDWindow-
IWDWindow-
Service IWDMessage
Manager
IWDComponent-
Info
Manager
IWDWindow-
Manager
Manager
Manager
Manager
Manager Info Manager
Interfaces
Use
implements
Interface Class extends
Interface
other relation
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Classes SampleComp
SampleComp ModelCust
ModelCust MainView
MainView
wdThis wdThis wdThis
wdControllerAPI
wdControllerAPI
wdThis
wdController
Generated Private Controller Interfaces
API
Private IPrivate-
IPrivate- IPrivate-
IPrivate- IPrivate-
IPrivate-
SampleComp
SampleComp ModelCust
ModelCust MainView
MainView
Interfaces
wdGetAPI() wdGetAPI() wdGetAPI()
wdGetAPI()
Generic Controller
Interfaces
IWDController
Internal
Only
IWDController
Generic IWDViewController
IWDComponent
IWDComponent IWDViewController
Interfaces getComponent()
IWDWindow-
IWDWindow-
IWDMessage IWDComponent- IWDWindow-
IWDWindow-
IWDWindow-
Service IWDMessage
Manager
IWDComponent-
Info
Manager
IWDWindow-
Manager
Manager
Manager
Manager
Manager Info Manager
Interfaces
Use
implements
Interface Class extends
Interface
other relation
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Use
SAP
SAP
SAP AG 2004
Partner
Use
The Web Dynpro Explorer displays the logical structure of the entire Web Dynpro Project. The nodes
Internal
Only
the menu. By default, this will add a new tab to the same window in which the Navigator and Project
Explorers appear.
If you want to activate the Web Dynpro Explorer after working with another tool, then choose the Web
Dynpro Explorer tab.
Internal
Only
Partner
View Controller
Custom Controller
Use
The Data Modeller can be used to define the
data sharing relationships between custom
controllers and view controllers.
SAP
SAP
SAP AG 2004
Partner
Use
Data Modeller
Within the Web Dynpro Explorer, you will find the Data Modeller. This is a graphical tool that shows
the relationship between the various controllers and models within one Web Dynpro Component. The
perspective area that displays the Data Modeller is the Diagram View.
Internal
The Data Modeller helps you perform the following development tasks:
y Controller creation
y Declaring the use of a custom controller by another controller
Only
y Declaring the use of a Model by the component
y Nesting Components
y Creating context mappings by means of data links
Opening the Data Modeller
To open the Data Modeller, either choose Open Data Modeller from the context menu for the component
name in the Web Dynpro Explorer or double click on the component name.
Internal
Only
Partner
Use
a Window.
Double click on the Window name or choose Open
Navigation Modeller from the context menu.
SAP
SAP
SAP AG 2004
Partner
Use
Navigation Modeller
The Navigation Modeller is a graphical Web Dynpro tool for designing and implementing the navigation
relationships that exist between the views in a Window. It is displayed in the Diagram View editor. The
Navigation Modeller allows you to create and change the following entities of a Web Dynpro Window:
Internal
y View Sets
y Views
y Plugs
Only
y Navigation Links
Opening the Navigation Modeller
You can start the Navigation Modeller by either choosing the context menu entry Open Navigation
Modeller for the window name in the Web Dynpro Explorer, or double clicking on the Window name.
What purpose does a Window serve?
A Web Dynpro window is the superset of all views that could possibly be displayed within the given
screen layout. At any one time only a subset of these views is ever visible.
What is a View Assembly?
From the superset of views defined within a Window, only a subset will ever be visible at any one time.
The visible subset of views is known the “View Assembly”. This is the set of views that are actually
rendered and sent to the client.
Internal
Only
Partner
Use
Double click on the
The tab Events is specific to a custom
Component Controller node
controller, but the other four tabs are
or Choose Edit from the
common to all controller types.
context menu.
SAP
SAP
SAP AG 2004
Partner
Use
The Web Dynpro Explorer provides various tools for editing all aspects of a controller. Irrespective of
the type, all controllers have the following editor tabs:
y Properties (Lists the required controllers)
Only
y Context (Runtime storage area used by all controllers)
y Methods (User defined instance methods; not for component interface view controllers )
y Implementation (Java editor for modifying the controller’s standard hook methods)
Custom Controller Editor
A custom controller has the following specific features:
y A Custom Controller has no visual interface. Therefore, the editor does not contain a “Layout” tab.
y A Custom Controller can raise server-side Events. Any method of any controller within the same
component can be defined as a listener for these events (once an appropriate usage declaration has first
been made).
View Layout
Internal
Only
Properties of the
selected UI element
Partner
Use
Double Click on the
Component Controller
Node or Choose Edit from Hierarchical arrangement of the UI
the context menu elements in the layout.
SAP
SAP
SAP AG 2004
Partner
Use
y A View Controller can respond to client side events via runtime objects known as “Actions”.
y Navigation takes place to and from View Controllers via “Plugs”. “Plugs” are special event handlers
that respond to either inbound or outbound navigation events.
Only
View Layout Editor
The View Designer is the graphical tool within the Web Dynpro Explorer that allows you to design and
build the user interface (UI) part of a View Controller.
Opening the View Designer
To open the View Designer, choose Edit from the context menu of the view in the Web Dynpro
Explorer; Navigation Modeller, or Data Modeller. Once the View Designer has been opened, you can
edit all the various UI elements within the View’s layout. If you want to enlarge the work area of any of
the editor windows, simply double-click on the editor window’s title bar and it will become full screen.
To revert to the original size, double-click on the title bar again.
Internal
Only
Partner
Use
context menu of Message Pool or double
click on the Message Pool node.
SAP
SAP
SAP AG 2004
Partner
Use
y The only languages that may be chosen are those in which an SAP R/3 system can operate.
y The Project or DC language is used only for translation purposes. It is not referenced at runtime.
Message Editor
Only
y Allows you to create and edit Web Dynpro specific text messages that you want to display on the
screen.
y Is only capable of editing texts in the Project’s or DC’s default language.
y Defines messages that are to appear on the user interface via the IWDMessageManager class.
Internal
Only
Partner
Use
SAP
SAP
SAP AG 2004
Partner
Use
Internal
Only
Internal
Only
Deploy
Web Service
Services (CBS)
(CMS)
Business Layer
Partner
EJB Design
Component
Model Time
Repository
Persistence (DTR)
Use
Local Local
JDBC SQLJ Open SQL File J2EE
System Engine
SAP
SAP
SAP AG 2004
Partner
Use
SAP provides to develop business applications. It combines the advantages of local development with
the strength of a central resource repository and supports development teams with numerous tools for
development of complex applications such as build processes.
Only
y Design Time Repository (DTR)
The DTR can be used to store development components centrally within a distributed development
and is responsible for version management.
y Component Build Service (CBS)
The DTR is closely associated with the CBS. The CBS is responsible for creating software
components on the basis of the SAP "Component Model" as a central build process.
y Change Management Service (CMS)
Once make processes have been completed successfully, the CBS forwards the results to the CMS.
The CMS is responsible for software logistics. This is the controlled distribution of software
components to defined targets within the development landscape.
DTR Server
Browser/ DTR Client DTR Client
WebFolder Client Commandline
Internal
Only
WebDAV
DeltaV+
Partner
DASL
Use
Local
File J2EE Server
System Developer's PC
SAP
SAP
SAP AG 2004
Partner
Use
Only
y DeltaV
DeltaV adds WebDAV versioning characteristics (http://www.webdav.org/deltav/).
y DASL
The DASL protocol allows a HTTP/1.1-compliant schema to be used for the server-side search
functionality.
The DTR manages the different versions of your software and also solves possible conflicting change
conditions that may be created by the various developers.
If you want to modify the software provided by SAP, you can use the DTR to do so without errors
occurring. The DTR ensures that the changes you make are compared with the software provided by
SAP.
Internal
Only
/FI/cons/ HR2
Use
HR2 Archives
FI 3 HR 2 build F1 F1 Archives
FI 4 TC TC Archives
SAP
SAP
SAP AG 2004
Partner
Use
such as how software is to be created from individual components, special instructions, known as make
files.
Component Build Process (CBS)
Only
The CBS Build Tool is based on the standard Apache-Ant and Velocity tools. One reason for SAP
providing a separate build tool with the CBS, is that the SAP component model contains several pre-
configured development component types (e.g. for Web Dynpro, Data Dictionary, Web Services etc)
with the corresponding additional information (such as "public part"). This information must be
evaluated before sources are actually compiled. A CBS can be run as follows (see diagram):
y The build process is triggered by the SAP NetWeaver Developer Studio.
y CBS searches for the resources and archives required automatically.
- The last change (HR2) from the Design Time Repository (DTR).
- Archives required from the CBS build space (HR1, FI and TC).
y The build process is started.
y The new archive created (HR2) is saved in the build space (HR_DEV).
y Deployment (e.g. to a central test system) takes place automatically (controlled by Change
Management Service, CMS).
Internal
Only
SAP NetWeaver
Developer Studio Change Management Service
nent
Build Deploy
Service
(CBS)
(CMS)
Use
Component Design
Model Time
Repository
(DTR)
Local Local
File J2EE
SAP
System Engine
SAP
SAP AG 2004
Partner
Use
Only
Create
Development Archive
Component Pool
Naming Naming Naming
Service Service Service
Service Service Service
Develop, build,
Internal
Only
Save /
load
Deploy and test locally Java
Sources Web Container
EJB Container
File J2EE Server
Check-in
system
changes
Partner
Component
Naming Naming Naming
Service Service Service
Build
Service Service Service
Use
Deploy
Web Container Activate OK? archives
EJB Container
J2EE Server
Local J2EE engine
SAP
SAP
SAP AG 2004
Partner
Use
DTR, pre-configured configurations and the results of the CBS help to create a standardized and stable
development environment at each work station.
Only