Professional Documents
Culture Documents
Marco Ertel
NW PM Operations AP, Web Dynpro PM, SAP AG
Bertram Ganz
NWF Application UI, Web Dynpro Java Runtime, SAP AG
Gaby Wenneker
NW DT Development Framework, SAP AG
Michael Wenz
NW DT Development Framework, SAP AG
Dynamic UI Manipulation
Dynamic Context Creation
Dynamic Action Creation
Dynamic Metadata
Designtime Runtime
Example
import com.sap.tc.webdynpro.clientserver.uielib.standard.api.*;
...
public static void wdDoModifyView (
IPrivateDynamicView wdThis,
Creates an Input Field
IPrivateDynamicView.IContextNode wdContext,
IWDView view, boolean firstTime)
{
//@@begin wdDoModifyView
if (firstTime) {
IWDInputField input = (IWDInputField)
view.getElement(”someInput”);
input.setEnabled(false);
}
//@@end
}
Example
public static void wdDoModifyView (
IPrivateDynamicView wdThis,
IPrivateDynamicView.IContextNode wdContext,
IWDView view, boolean firstTime)
{
//@@begin wdDoModifyView
…
//@@end
}
firstTime of the type boolean: This is true only if wdDoModifyView is called for the first
time during the life cycle of the corresponding view.
view: Reference to the layout controller of the view.
wdThis: Reference to the IPrivate interface of the view controller . wdThis allows access
to the controller context; it also allows triggering outbound plugs and events and access to
action objects as well as controllers used.
wdContext: Reference to the root context node of the view controller (for the current
context).
Example
IWDInputField input =
(IWDInputField)view.getElement("someInput");
input.setEnabled(false);
Example
view.createElement(IWDInputField.class, "InputField1");
Once you have created your UI element you can modify it’s default
properties.
Example
To position a UI element in your view you must first get access to the UI
Container you want to add it to (First line of code above).
You can then call the container method addChild(IWDUIElement) or
addChild(IWDUIElement, int index) to place the UI element in it.
Example
//@@begin wdDoModifyView
if (wdContext.currentContextElement().getVisible()) {
IWDLabel label2 = (IWDLabel)view.getElement("Label2");
label2.setEnabled(true);
IWDLabel label3 = (IWDLabel)view.getElement("Label3");
label3.setVisible(WDVisibility.VISIBLE);
IWDUIElementContainer container = label2.getContainer();
IWDLabel label4 =
(IWDLabel)view.createElement(IWDLabel.class, "Label4");
label4.setText("Dynamically Created Label!");
container.addChild(label4, 2);
}
//@@end
© SAP AG 2004, SAP TechEd / PRTL351 / 14
Dynamic Context Creation
Example
wdContext.currentContextElement().
setAttributeValue("AttributeA", null);
inputfield.bindValue("AttributeA");
To access this interface for the Root Node you must call the method:
wdContext.getNodeInfo().
Example
rootNode.addAttribute("MyAttribute",
"ddic:com.sap.dictionary.string");
For each node that you create at design time, a method is generated on
wdContext to access that nodes IWDNodeInfo interface.
wdContext.nodeTestNode2().getNodeInfo()
wdContext.nodeTestNode().getNodeInfo()
Example
wdContext.currentContextElement().
setAttributeValue("AttributeA", null);
inputfield.bindValue("AttributeA");
wdContext.currentMyNodeElement();
wdContext.currentContextElement().setResult(result);
Attributes:
wdContext.currentContextElement().getAttributeValue(String)
The below code shows the creation of a node and an underlying attribute of that node:
Now we can bind a input field’s value to this node – binding context values to UI elements should occur in
wdDoModifyView():
theInput.bindValue("DynamicNode." + fld.getName());
Once the binding has occurred we need to access the context variable to get the users input – this is
generally done in an action event handler:
IWDNode node =
wdContext.currentContextElement().node().getChildNode("DynamicNode", 0);
IWDNodeElement nodeElement = node.getCurrentElement();
String myAttr = (String)nodeElement.getAttributeValue("MyAttr");
Example
IWDAction theAction =
wdThis.wdCreateAction(IPrivateDynamicView.WDActionEventHandler.GE
NERIC_ACTION,"");
theButton.setOnAction(theAction);
1. Obtain the name of the parameter associated with the UI elements event
(For example: IWDCheckBox has a parameter associated with event
onToggle named “checked”).
2. Create an action in the view controller.
3. Define a parameter for the action of the same data type as the event
parameter.
4. Associate the event parameter with the action parameter.
Server
Example
if (firstTime) {
// Get a reference to the checkbox UI element
IWDCheckBox cb =
(IWDCheckBox)view.getElement("myCheckBox");
// Link the client-side event parameter ‘checked’ to
// the server-side action parameter ‘checkBoxState’
cb.mappingOfOnToggle().addSourceMapping("checked",
"checkBoxState");
}
Can create multiple actions that point to the same event handler.
Example
IWDAction theAction =
wdThis.wdCreateAction(
IPrivateDynamicView.WDActionEventHandler.GENERIC_ACTION,"")
;
theButton.setOnAction(theAction);
theButton.mappingOfOnAction().addParameter("Command", "delete");
theActionContainer.addChild(theButton);
Dynamic Metadata
General Overview
How to start debugging
How to use the debug view
How to inspect data and status while debugging
Demo
Breakpoint options
Use the context menu on a breakpoint to set conditions
and breakpoint properties
Set
breakpoint
by double
clicking
Optionally
edit
breakpoint
properties
3. Specify
Specify project and
appropriate application
debugging
configuration
and start
debugging
1. Start
debugging
2. Create
4. Start debug
debugging
session
configuration
Debug view
Allows you to manage the debugging of a program in the
IDE
Displays the stack frame for the suspended threads you
are debugging (thread = node in the tree).
Editor view
Displays program line the debugger is currently executing
If the program execution leads to a different class, Eclipse
will open up the corresponding editor automatically
Variables view
Shows information about variables that are currently in scope
(currently-selected stack frame and callstack)
Hierarchical display of variable structure
Content of variables can be checked in separate content area
(based on toString() method)
Content of variables may be changed
Breakpoints view
Shows a list of the currently set breakpoints and their state
Allows to
Add new exception breakpoints
Delete existing breakpoints
Change the properties of existing breakpoints
Expressions view
Used to evaluate results of expressions
Hierarchical display of structure
Content area (based on toString() method)
“Inspect” command
Watch expressions
Display view
Used to evaluate results of expressions
String-only representation of result (based on toString() method)
“Display” command
Used to evaluate own expressions
Simply type expression
Use code completion
“Inspect” and “Display” possible
The
debugging
perspective Debug view: Variables view:
info on variables
allows to stacktraces for
each suspended currently in scope
manage and
thread
run the
debugging
session
Display view:
text based expression
evaluation
Editor view:
currently executed
code
4. Start debug
session
Expressions view:
tree based expression
Breakpoints view: evaluation
list of breakpoints
Suspend
Will pause execution and allows to view state of variables
Resume [F8]
This command resumes a suspended thread
Terminate
Will terminate execution of the program
Step with
There are filters
various
Step into
different
Terminate Step over
options for
further Suspend
processing Step return
Resume
Enter airline ID
View details on
flight in form view
IDE
StartWeb Dynpro application from Web Dynpro explorer or run
configuration
Server does not need to be in debug mode
Activate HTTP
debugging before
setting a breakpoint
Debugging Overview
Activate debugging mode for server node
Set breakpoints
Specify debugging configuration
Use debugging perspective (debug view, variables view,…)
Exercise
different
locales
Web Dynpro
Component A
Externalize Create
Strings Archive
Local
Dictionary
Java Property
Resource Bundles
© SAP AG 2004, SAP TechEd / PRTL351 / 60
Externalizing Strings inside a Web Dynpro Project
xlf
file
Please note that this document is subject to change and may be changed by SAP at
any time without notice. The document is not intended to be binding upon SAP to any
particular course of business, product strategy and/or development.
© SAP AG 2004, SAP TechEd / PRTL351 / 63
Translation of XLF-Files
Dictio-
nary
different
locales
xlf
file Web Dynpro
Tools Project
create
Compo- transfer texts EAR
archive
nent into property File
files
deployable
xlf
project
file
Simple
Data Type
xlf
file
View View
View Window Messages
View Window
Controller and Texts
S2X Editor
XLF-files
<View Name>.wdview_de.xlf
xlf <View Name>.wdview_en.xlf
file <View Name>.wdview.xlf
© SAP AG 2004, SAP TechEd / PRTL351 / 68
Locale-dependant texts inside a View Controller
S2X Editor
XLF-files
<View Name>.wdcontroller_de.xlf
xlf <View Name>.wdcontroller_en.xlf
file <View Name>.wdcontroller.xlf
© SAP AG 2004, SAP TechEd / PRTL351 / 69
Locale-dependant texts inside a Window
S2X Editor
XLF-files
<View Name>.wdwindow_de.xlf
xlf <View Name>.wdwindow_en.xlf
file <View Name>.wdwindow.xlf
© SAP AG 2004, SAP TechEd / PRTL351 / 70
Message Pool inside a Web Dynpro Component
XLF-files
<Component Name>MessagePool.wdmessagepool_de.xlf
xlf <Component Name>MessagePool.wdmessagepool_en.xlf
file <Component Name>MessagePool.wdmessagepool.xlf
IMessage-
<Component>
Property
Web Dynpro IWDText- Files for
Controller Accessor Session
Locale
ISimpleType
Deployed Project
IMessage-
<Component>
//@@begin javadoc:onActionRent(ServerEvent)
/** Declared validating event handler. */
//@@end
public void onActionRent(
com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent ){
//@@begin onActionRent(ServerEvent)
String vehicleType =
wdContext.currentContextElement().getVehicleType();
if (vehicleType == null) {
IWDMessageManager msg = wdComponentAPI.getMessageManager();
msg.reportMessage(
IMessageLanguagesComp.NO_CAR, null, false);
} else {
wdThis.wdFirePlugOutRent(vehicleType);
}
//@@end
}
IMessage-
<Component>
IWDTextAccessor
//@@begin javadoc:onPlugInResult(ServerEvent)
/** Declared validating event handler. */
//@@end
public void onPlugInResult(
com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent,
java.lang.String vehicleType ) {
//@@begin onPlugInResult(ServerEvent)
IWDTextAccessor textAccessor =
wdComponentAPI.getTextAccessor();
String text = textAccessor.getText("text_E");
//@@end
}
different
Web Dynpro locales
Component A
Externalize
Deprecated Strings
Web Dynpro
Only needed in older Project
Component B EAR
versions where no texts Build
Web
can be added to theDynpro File
Tools
message pool Deployable
Local Project
Dictionary
read
property
send UI
file Web
containing
deployed language Dynpro UI
EAR project dependant texts
en
Exercise
WDValueServices
WDValueServices
IWDOVSContextNotificationListener
IWDOVSContextNotificationListener
<<inner
<<innerclass>>
class>>
OVSDemoListener
OVSDemoListener
to be implemented by application developer
…
DepCity
Arrival
…
ArrCity
Context attributes
Output
have to be properly
0..n
Lufthansa
typed for the
generic OVS UI
… Bonn
WDValueServices
WDValueServices
-addOVSExtension(
-addOVSExtension(
IWDAttributeInfo[]
IWDAttributeInfo[]startupAttributes,
startupAttributes,
IWDNode
IWDNode queryInputNode, //
queryInputNode, //lead
leadselection
selectionpointing
pointingto
toelement
element
IWDNode
IWDNodequeryResultNode,
queryResultNode, ////caridinality
caridinality0..n
0..n
IWDOVSContextNotificationListener queryListener…)
IWDOVSContextNotificationListener queryListener…)
IWDOVSContextNotificationListener
IWDOVSContextNotificationListener
--appyInputValues(
appyInputValues(IWDNodeElement
IWDNodeElementovsRequestingElement,
ovsRequestingElement,
IWDNodeElement
IWDNodeElementqueryInputNodeElement)
queryInputNodeElement)
- -onQuery(
onQuery(IWDNodeElement
IWDNodeElementqueryInput,
queryInput,IWDNode
IWDNodequeryOutput)
queryOutput)
- -applyResult( IWDNodeElement ovsRequestingElement,
applyResult( IWDNodeElement ovsRequestingElement,
IWDNodeElement
IWDNodeElementqueryOutputElement)
queryOutputElement)
Web Dynpro
Runtime View
OVS Listener
Controller
Request OVS
call OVS-Listener hook
Service Request
applyInputValues()
Specify Search
and Press Go
call OVS Listener hook
OVS Action
onQuery()
Select Result
call OVS Listener hook
OVS Action applyResult()
data binding
View Context
Root Node
0..1
Flight
AirlineId OVS
DepCity
…
ArrCity
OVS
Flight
0..1
LH
…
Node Element
Collection
OVSSearchInput
1..1 OVS
LH Helper
Context
…
OVSSearchOuput
0..n
… and another 0..n node for the query result table entries.
OVSSearchInput
1..1
LH
…
OVSSearchOuput
0..n
1..1
LH
…
OVSSearchOuput
0..n
OVSSearchInput
1..1
LH
…
OVSSearchOutput
0
1
0..n n
LH
LH
…
… LH
Bonn
New
…
York London
The user selects a line in the OVS search result table and
the OVS listener hook applyResult() is called. Values of the
selected query result can be copied to the source context.
1..1 Flight
LH 0..1
…
LH
FRA
…
OVSSearchOutput New
0 York
1
0..n n
LH
LH
…
… LH
Bonn
New
…
York London
OVS
Output
0..1
Flight_List OVS Output Node
0..n
LH
Bonn
OVS does not support nested structures yet: the OVS query
input and output attributes (inside the OVS Helper Context) must
be contained in one input and one output node.
Exercise
Î Public Web:
www.sap.com
SAP Developer Network: www.sdn.sap.com Î Web Application Server Î
Web Dynpro
SAP Developer Network: www.sdn.sap.com Î Web Application Server Î
Web Dynpro Î Web Dynpro Articles
„Debugging a Web Dynpro Application“
„Debugging ABAP Code from within Web Dynpro Applications“
SAP Customer Services Network: www.sap.com/services/
Coming in December.
http://www.sdn.sap.com/
Q&A
Thank You !