Contents:
Dynamic Programming Overview
Dynamic User Interfaces
Dynamic Contexts
Dynamic Actions
Designtime
Runtime
Example
import com.sap.tc.webdynpro.clientserver.uielib.standard.api.*;
...
public static void wdDoModifyView (
Gets an Input Field
IPrivateDynamicView wdThis,
IPrivateDynamicView.IContextNode wdContext,
IWDView view, boolean firstTime)
and disables it.
{
//@@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 wis called
for the first time during the life cycle of the corresponding view.
view: Reference to the generic view controller API, suitably typed to offer
special view functionality like creating UI elements.
wdThis: Reference to the IPrivate interface of the view controller . wdThis
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).
SAP AG 2003, Title of Presentation, Speaker Name / 7
Example
IWDInputField input =
(IWDInputField)view.getElement("someInput");
input.setEnabled(false);
Example
IWDInputField inputfield = (IWDInputField)
view.createElement(IWDInputField.class, "InputField1");
Example
IWDTransparentContainer container = (IWDTransparentContainer)
view.getElement("RootUIElementContainer");
IWDInputField inputfield = (IWDInputField)
view.createElement(IWDInputField.class, "InputField1");
container.addChild(inputfield);
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.
SAP AG 2003, Title of Presentation, Speaker Name / 11
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 2003, Title of Presentation, Speaker Name / 12
"
Interface IWDNodeInfo allows programmers to add all kinds of context types to the
context tree.
To access this interface for the Root Node you must call the method:
wdContext.getNodeInfo().
Example
IWDNodeInfo rootNode = wdContext.getNodeInfo();
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 the node instance and from there you can access that nodes IWDNodeInfo
interface.
Example:
#
#
$
$
"
"
%&'# "
&'# "
&'
&'
()
Example
IWDAttributeInfo test =
Create an Attribute
wdContext.getNodeInfo().
addAttribute("AttributeA",
"ddic:com.sap.dictionary.string");
wdContext.currentContextElement().
setAttributeValue("AttributeA", "Hello World!!!");
inputfield.bindValue(test);
Bind the newly
created attribute to
the input field
SAP AG 2003, Title of Presentation, Speaker Name / 16
Attributes:
wdContext.currentContextElement().getAttributeValue(String)
The below code shows the creation of a node and an underlying attribute of
that node:
IWDNodeInfo node = wdContext.getNodeInfo().
addChild("DynamicNode", null, true, true, false, false, false,
true, null, null, null);
node.addAttribute("MyAttr", ddic:com.sap.dictionary.string");
Now we can bind a input fields value to this nodes attribute binding context
values to UI elements should occur in wdDoModifyView():
theInput.bindValue("MyAttr");
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");
(
Client
DynamicView
onToggle(boolean checked)
Server
Request
Network
}
}
(
This example uses the CheckBoxs
onToggle action to further illustrate how
to implement parameter mapping.
First we create an action in a view
controller to handle the change of state
in a checkbox UI element.
The checkbox is called myCheckBox
and will be associated with an action
called HandleCheckBox.
Define a parameter called
checkBoxState of type boolean for the
action handler method
onActionHandleCheckBox.
+)
+)
Can create multiple actions that point to the same event handler.
Can create constant parameters on UI element actions and map them to the
parameters of an event handler:
Example
IWDAction theAction =
wdThis.wdCreateAction(
IPrivateDynamicView.WDActionEventHandler.GENERIC_ACTION,"");
theButton.setOnAction(theAction);
theButton.mappingOfOnAction().addParameter("Command", "delete");
theActionContainer.addChild(theButton);
+)
+
#
. )
"
. %112 )
3#
No part of this publication may be reproduced or transmitted in any form or for any purpose without the express
permission of SAP AG. The information contained herein may be changed without prior notice.
Some software products marketed by SAP AG and its distributors contain proprietary software components of other
software vendors.
Microsoft, WINDOWS, NT, EXCEL, Word, PowerPoint and SQL Server 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, Informix
and Informix Dynamic ServerTM are trademarks of IBM Corporation in USA and/or other countries.
ORACLE is a registered trademark of ORACLE Corporation.
UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group.
Citrix, the Citrix logo, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, MultiWin and other
Citrix product names referenced herein are trademarks of Citrix Systems, Inc.
HTML, DHTML, XML, XHTML 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.
MarketSet and Enterprise Buyer are jointly owned trademarks of SAP AG and Commerce One.
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.