Dynamic Runtime Manipulation-Context & View Layout Using Web Dynpro For Java
Dynamic Runtime Manipulation-Context & View Layout Using Web Dynpro For Java
Customer-Business Case
There might be some scenarios where in we need to dynamically add nodes, their attributes to the view controller context. In this case the View Layout needs
to be defined dynamically using the above context nodes and the attributes.
Package com.sap.training
Click on “Finish”:
Since everything in this component will be created dynamically at runtime, both the view context and the view layout will remain empty.
View Context :
We can find here the context is empty. The context will be creating dynamically at runtime.
soNode.addElement(soElement);
//@@end
}
Now the Node SalesOrder IS created with the following Attributes:
SalesOrder (node)
OrderNo :ddic:com.sap.dictionary.integer
SalesDate: ddic:com.sap.dictionary.date
SalesRep: ddic:com.sap.dictionary.string
LongText: ddic:com.sap.dictionary.string
Part 2: Creating View Layout Dynamically
For the above Created Dynamic Context we ar going to create View layout.
Locate The method WDDOModfify view
public static void wdDoModifyView(IPrivateMainView wdThis, IPrivateMainView.IContextNode
wdContext,com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
{
//@@begin wdDoModifyView
if (firstTime) {
IWDTransparentContainer rootElement =
(IWDTransparentContainer) view.getRootElement();
rootElement.createLayout(IWDMatrixLayout.class);
IWDNodeInfo soNodeInfo =
wdContext.getChildNode("SalesOrders", 0).getNodeInfo();
label.setText(soAttrInfo.getName());
label.createLayoutData(IWDMatrixHeadData.class);
label.setDesign(WDLabelDesign.LIGHT);
label.setLabelFor(soAttrInfo.getName() + "Input");
rootElement.addChild(label);
IWDInputField ioField =
(IWDInputField) view.createElement(
IWDInputField.class,
soAttrInfo.getName() + "Input");
ioField.createLayoutData(IWDMatrixData.class);
ioField.bindValue(soAttrInfo);
rootElement.addChild(ioField);
}
// @@end
}
Enter The name Of Application
Click on “Next”
Click on “Next”
Click on Finish
Output :