on 02-18-2008 12:02 PM
Hi Experts,
I have an issue with Dynamic Table creation. This is the situation. I have an XML Where in i store table rows and columns. when the page loads i have to read the XML and i have to create row and columns dynamically as in the XML. I have done this . Problem is , i user wants to add a new column. i am giving one pop up window , where in i am getting column name. when pop up window closed, the dynamic table was not there .
What i am doing wrong?
I am creating dynamic table in init method. is it if control goes to anther window all context info will be lost?
Please help me on this.
Thank you,
Regrads,
Senthil
Hi,
"I am creating dynamic table in init method. is it if control goes to anther window all context info will be lost?"
Dont store the view instance.
Create the table in the wdDomidifyView based on a condition either isFirstTime or else your custom one.
It would be really helpfull if you could post the code.
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ayyapparaj,
This is the code
public void wdDoInit()
{
//@@begin wdDoInit()
//Add Buttons
IWDView view = (IWDView)this.wdControllerAPI;
XMLParseWrite pars = new XMLParseWrite();
IWDNodeInfo tabNode=wdContext.getNodeInfo().addChild("sharedData", null,true, true, true,false,true,false,null,null,null);
IWDTransparentContainer root = (IWDTransparentContainer)view.getRootElement();
// Add Master Data Button Creation
IWDButton addMasterData = (IWDButton)view.createElement(IWDButton.class,"AddMasterData");
addMasterData.setText("AddMasterData");
root.addChild(addMasterData);
// Action Creation for Add masterData Button
IWDAction addmd = wdThis.wdCreateAction(IPrivateMDMView.WDActionEventHandler.GENERIC_ACTION, "AddMasterdataAction");
addMasterData.setOnAction(addmd);
WDDeployableObjectPart dobp = wdComponentAPI.getDeployableObjectPart();
String path=null;
try{
path = WDURLGenerator.getResourcePath(dobp,"TestRun.xml");
}catch(WDAliasResolvingException e){
wdComponentAPI.getMessageManager().reportSuccess(e.getMessage());
}
File f = new File(path);
// wdComponentAPI.getMessageManager().reportSuccess(path"status"f.exists());
Document d = pars.parseXML(path);
NodeList root_nod = d.getElementsByTagName("SharedMasterData");
// Creating Dynamic nodes and data for Master Data
ArrayList al = pars.getChileNodesByName(root_nod.item(0), "LineItem");
Node lineitem[] = new Node[al.size()];
Iterator it = al.iterator();
int len= 0;
while(it.hasNext()){
lineitem[len] = (Node)it.next();
len++;
}
Node masterData[] = pars.getOnlyElementChildNodes(lineitem[0].getChildNodes());
String[] masterDataName = new String[masterData.length];
for(int i = 0;i < masterData.length;i++)
{
Node n = masterData<i>;
masterDataName<i> = n.getNodeName();
tabNode.addAttribute(masterDataName<i>, "ddic:com.sap.dictionary.string");
}
// IWDAttributeInfo tabAttrib1 = tabNode.addAttribute("ProductID", "ddic:com.sap.dictionary.string");
// IWDAttributeInfo tabAttrib2 = tabNode.addAttribute("PartyID", "ddic:com.sap.dictionary.string");
// IWDAttributeInfo tabAttrib3 = tabNode.addAttribute("Count", "ddic:com.sap.dictionary.string");
IWDTable table = (IWDTable)view.createElement(IWDTable.class,"TestDataTable");
table.bindDataSource(tabNode);
// table.setCompatibilityMode(WDTableCompatibilityMode.AUTO);
table.setDesign(WDTableDesign.ALTERNATING);
IWDTableColumnGroup MasterDataGroup = (IWDTableColumnGroup)view.createElement(IWDTableColumnGroup.class,"MasterData");
IWDCaption caption = (IWDCaption)view.createElement(IWDCaption.class,"colGroupCaption");
caption.setText("MasterData");
MasterDataGroup.setHeader(caption);
for(int i=0;i<masterDataName.length;i++)
{
IWDAttributeInfo attrbt = tabNode.getAttribute(masterDataName<i>);
IWDTableColumn col = (IWDTableColumn)view.createElement(IWDTableColumn.class,masterDataName<i>);
IWDCaption colcap1 = (IWDCaption)view.createElement(IWDCaption.class,"MasterDataCaption"+i);
colcap1.setText(masterDataName<i>);
col.setHeader(colcap1);
IWDTextView celleditor = (IWDTextView)view.createElement(IWDTextView.class,"MDtextView"+i);
celleditor.bindText(attrbt);
col.setTableCellEditor(celleditor);
MasterDataGroup.addColumn(col);
}
// Static data Reacding part
table.addGroupedColumn(MasterDataGroup);
NodeList st_root_nod = d.getElementsByTagName("SharedStaticData");
// Creating Dynamic nodes and data for Master Data
ArrayList al2 = pars.getChileNodesByName(st_root_nod.item(0), "LineItem");
Node st_lineitem[] = new Node[al2.size()];
Iterator it2 = al2.iterator();
int len2= 0;
while(it2.hasNext()){
st_lineitem[len2] = (Node)it2.next();
len2++;
}
Node staticData[] = pars.getOnlyElementChildNodes(st_lineitem[0].getChildNodes());
// wdComponentAPI.getMessageManager().reportSuccess("Size"al2.size()staticData.length);
String[] staticDataName = new String[staticData.length];
for(int i = 0;i < staticData.length;i++)
{
Node n = staticData<i>;
staticDataName<i> = n.getNodeName();
tabNode.addAttribute(staticDataName<i>, "ddic:com.sap.dictionary.string");
}
if(staticData.length>0)
{
IWDTableColumnGroup staticDataGroup = (IWDTableColumnGroup)view.createElement(IWDTableColumnGroup.class,"StaticData");
IWDCaption staticcaption = (IWDCaption)view.createElement(IWDCaption.class,"colGroupCaption1");
staticcaption.setText("StaticData");
staticDataGroup.setHeader(staticcaption);
for(int i=0;i<staticDataName.length;i++)
{
IWDAttributeInfo attrbt = tabNode.getAttribute(staticDataName<i>);
IWDTableColumn col1 = (IWDTableColumn)view.createElement(IWDTableColumn.class,staticDataName<i>);
IWDCaption colcap1 = (IWDCaption)view.createElement(IWDCaption.class,"StaticDataCaption"+i);
colcap1.setText(staticDataName<i>);
col1.setHeader(colcap1);
IWDTextView celleditor = (IWDTextView)view.createElement(IWDTextView.class,"STtextView"+i);
celleditor.bindText(attrbt);
col1.setTableCellEditor(celleditor);
staticDataGroup.addColumn(col1);
}
table.addGroupedColumn(staticDataGroup);
}
// table.addGroupedColumn(col2);
table.createLayoutData(IWDRowHeadData.class);
table.setWidth("500");
IWDNode node = (IWDNode)wdContext.getChildNode("sharedData",0);
for(int i=0;i<lineitem.length;i++)
{
IWDNodeElement ele = (IWDNodeElement)node.createElement();
Node masterDatas[] = pars.getOnlyElementChildNodes(lineitem<i>.getChildNodes());
for(int j=0;j<masterDatas.length;j++)
{
ele.setAttributeValue(masterDatas[j].getNodeName(), masterDatas[j].getTextContent());
}
Node staticDatas[] = pars.getOnlyElementChildNodes(st_lineitem<i>.getChildNodes());
for(int k=0;k<staticDatas.length;k++)
{
ele.setAttributeValue(staticDatas[k].getNodeName(), staticDatas[k].getTextContent());
}
node.addElement(ele);
}
root.addChild(table);
//@@end
}
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.