cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Table

Former Member
0 Kudos

Hi,

Can any one tell how to create dynamic table in Web DynPro through java Programming.

Thanks,

Ashvitha j.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Karthikeyan,

I have tried your code.The last object shouldnot be 'test' it should be 'rootElement'.And in my requirement action tab is not reqired so I have not created any Action.But I am still getting internal server error.Anything need to add.

Thanks,

Former Member
0 Kudos

Hi,

yes,i made mistake in that code.now i changed it. but no need to add anything to create this dynamic table. please try again.

Former Member
0 Kudos

Hi Karthikeyan Ramasamy,

Still I am not getting Result. It is s showing Internal Server Error. Is it the way to declare node and attribute in wdDoModifyView. Is it necessary to declare in the wdDoInit Method.

Thanks,

Former Member
0 Kudos

Hi

Download this source for the Dynamic creation of UI Elements

<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sapportals.km.docs/business_packages/a1-8-4/17tutwd_dynamic.zip">Dynamic.zip</a>

Kind Regards

Mukesh

Former Member
0 Kudos

Hi Ashvitha,

It is working fine for me. please check the other codes which are written in DoInit and DoModifyView or can you post your DoModifyView code here?

Former Member
0 Kudos

Hi Ashvitha

It is very late reply...I was getting also same problem.This error is because of Caption..If u comment that caption whole line then ur programm will run but without column name .My NWDS version is 7.0.0.Here the caption is not taking. is showing Internal Server Error.If u deploy in different version NWDS then it will definitely work.Just check.

Suman

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Have look at the following sample code. and try it with your own data. this will create a table and context node and attributes for that table dynamically.

IWDTransparentContainer rootElement = (IWDTransparentContainer)view.getRootElement();

IWDNodeInfo tabNode=wdContext.getNodeInfo().addChild("Tab_Node",null,true,true,true,false,true,false,null,null,null);

IWDAttributeInfo tabAttrib_Name=tabNode.addAttribute("Name","ddic:com.sap.dictionary.string");

IWDAttributeInfo tabAttrib_Add=tabNode.addAttribute("Address","ddic:com.sap.dictionary.string");

IWDTable tab=(IWDTable)view.createElement(IWDTable.class,"Dyntable");

IWDAttributeInfo attrib1=tabNode.getAttribute("Name");

IWDAttributeInfo attrib2=tabNode.getAttribute("Address");

tab.bindDataSource(tabNode);

tab.setCompatibilityMode(WDTableCompatibilityMode.AUTO);

tab.setDesign(WDTableDesign.ALTERNATING);

IWDTableColumn tabColumn1=(IWDTableColumn)view.createElement(IWDTableColumn.class,"NameCol");

IWDTableColumn tabColumn2=(IWDTableColumn)view.createElement(IWDTableColumn.class,"AddressCol");

IWDCaption nameCap=(IWDCaption)view.createElement(IWDCaption.class,"nameCap");

nameCap.setText("Name");

tabColumn1.setHeader((IWDCaption)nameCap);

IWDCaption addCap=(IWDCaption)view.createElement(IWDCaption.class,"addCap");

addCap.setText("Address");

tabColumn2.setHeader((IWDCaption)addCap);

IWDInputField nameText=(IWDInputField)view.createElement(IWDInputField.class,"nameText");

nameText.bindValue(attrib1);

tabColumn1.setTableCellEditor((IWDTableCellEditor)nameText);

IWDInputField addText=(IWDInputField)view.createElement(IWDInputField.class,"addText");

addText.bindValue(attrib2);

tabColumn2.setTableCellEditor((IWDTableCellEditor)addText);

tab.addColumn(tabColumn1);

tab.addColumn(tabColumn2);

tab.createLayoutData(IWDRowHeadData.class);

tab.setWidth("300");

IWDNode dynTabNode=(IWDNode)wdContext.getChildNode("Tab_Node",0);

for(int i=0; i<5;i++)

{

IWDNodeElement dynTabElem=(IWDNodeElement)dynTabNode.createElement();

dynTabElem.setAttributeValue("Name","Karthik");

dynTabElem.setAttributeValue("Address","Chennai");

dynTabNode.addElement(dynTabElem);

}

rootElement.addChild(tab);

// you should create one action for the table lead selection

IWDAction tabact=(IWDAction)wdThis.wdGet<Actionname>();

tab.setOnLeadSelect(tabact);