on 06-26-2007 8:19 AM
hi friends,
I need some sample code and procedure to create UI elements in runtime
help me...
waiting for reply....
Hi,
Check the following link for creating dynamic UI elements with code,
http://help.sap.com/saphelp_nw70/helpdata/en/89/73a840bd6d3c13e10000000a155106/frameset.htm
<a href="http://help.sap.com/saphelp_nw70/helpdata/en/89/73a840bd6d3c13e10000000a155106/frameset.htm">Dynamically Creating the Form</a>
<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/74cda090-0201-0010-6b91-f85b2489f765">Sample Apllications</a>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Some general info about dynamic UI generation
1.UI generation during runtime is done only in wdDoModifyView method of your view controller.
2. Always use if(firsttime){code for UI generation}.This will create the UI only once.
Else for every change/acton in the view wdDoModifyView will be called and it will try to create a duplicate UI element which will lead to errors.
3. For dynamic UI generation you have to first create the element
IWD<UI element> <some name> = IWD(UI element)view.createElement(IWD<UI Element>.class,"<ID of the UI element>");
for Inputfield
IWDInputField input = (IWDInputField)view.createElement(IWDInputField.class,"inputName");
4. Now on the instance i.e <some name> you can set the propertiese of the UI element as <some name>.set<UI element property>
5. Once you create ans set the required property for the UI element, you have to add that UI element to the Container.
If you have only one container then
IWDTransparentContainer container = (IWDTransparentContainer)view.getRootElement();
6. Add the dynamically created UI element to the container
container.addChild(<some name>);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Balaji,
Check the following links,they will surely help u ,
the following link tells u all abt dynamic creation of UI elements
following is one exercise,
Dont forget to Reward me with points if the answer is helpful to you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Balaji,
Here i give some example code of creating an UI Component in runtime in WebDynpro,
first u create a view,
and u enter this code for wdDoInit( )
//get reference to a meta data for context root node
IWDNodeInfo rootnodeInfo=wdContext.getNodeInfo();
//create a new meta data object for a node sales ordes
IWDNodeInfo soNodeInfo =rootNodeInfo.addChild("SalesOrders",
null,
true,
false, true,
false, false,
true,
null,
null,
null);
//create a four attripute in new salesorder
soNodeInfo.addAttribute("OrderNo",
"ddic:com.sap.dictionary.integer");
soNodeInfo.addAttribute("SalesDate",
"ddic:com.sap.dictionary.date");
soNodeInfo.addAttribute("SalesRep",
"ddic:com.sap.dictionary.string");
soNodeInfo.addAttribute("LongText",
"ddic:com.sap.dictionary.string");
//get ref to instence the sales order
IWDNode soNode = wdContext.getChildNode("SalesOrders", 0);
//create a new selection
IWDNodeElement soElement = soNode.createElement();
soElement.setAttributeValue("OrderNo", QHZ Integer(100));
soElement.setAttributeValue("SalesDate",
new Date(System.currentTimeMillis()));
soElement.setAttributeValue("SalesRep", "Homer Simpson");
soElement.setAttributeValue("LongText", "Printer Supplies");
soNode.addElement(soElement);
}
and write the code for wdModifyView()
if(firstTime)
{
IWDTransparentContainer rootElement=(IWDTransparentContainer)view.getRootElement();
rootElement.createLayout(IWDMatrixLayout.class);
IWDNodeInfo NnodeInfo=wdContext.getChildNode("SalesOrders",0).getNodeInfo();
for(Iterator iter=NnodeInfo.iterateAttributes();iter.hasNext();)
{
IWDAttributeInfo NAttrinfo=(IWDAttributeInfo)iter.next();
IWDLabel label=(IWDLabel)view.createElement(IWDLabel.class,NAttrinfo.getName()+"Label");
label.setText(NAttrinfo.getName());
label.createLayoutData(IWDMatrixHeadData.class);
label.setDesign(WDLabelDesign.LIGHT);
label.setLabelFor(NAttrinfo.getName()+"Input");
rootElement.addChild(label);
IWDInputField iofield=(IWDInputField)view.createElement(IWDInputField.class,NAttrinfo.getName()+"Input");
iofield.createLayoutData(IWDMatrixData.class);
iofield.bindValue(NAttrinfo);
rootElement.addChild(iofield);
}
}
Message was edited by:
Vinoth Raja.V
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Balaji,
Here is the Code for Creating Label UI Element Dynamically.
if(firstTime)
{
IWDTransparentContainer rootElement =(IWDTransparentContainer) view.getRootElement();
IWDLabel label =(IWDLabel) view.createElement(
IWDLabel.class,
"LabelName" + "Label");
label.setText(SampleText);
label.createLayoutData(IWDMatrixHeadData.class);
label.setDesign(WDLabelDesign.LIGHT);
label.setLabelFor(soAttrInfo.getName() + "Input");
rootElement.addChild(label);
}
Place this code in WDDoModifyView() so that it will be added only once to the screen because of FirstTime variable.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.