Uploading Excel files of unkown structure to Web Dynpro, Part One - Preview, Uploading Excel files of unkown structure to Web Dynpro, Part Two - Reading in the excel
In this part of my blog I will show you how to dynamically create a table UI element to
host the excel table we just uploaded. In the method wdDoModify() we add the following code:
try
{
//Get the row that contains the header
ArrayListrow = getHeader_row();
IWDTransparentContainer container = (IWDTransparentContainer)
view.getElement("TargetContainer");
if (!firstTime)
{
// Get node 'Table'
IWDNodeInfo tableInfo = wdContext.getChildNode("Table", 0).getNodeInfo();
//Each UI element receives an I.D on creation. If the I.D exists get it and destroy the element
String id = wdContext.currentViewElement().getTableId();
if (id != null)
{
view.getElement(id).destroy();
}
IWDTable tableUI = view.createElement(IWDTable.class);
tableUI.setDisplayEmptyRows(false);
// save the I.D. for later
wdContext.currentViewElement().setTableId(tableUI.getId());
if (row.size() > 0)
{
//for each row of the table create all columns and insert a text view into each cell
for (int j = 0; j < row.size(); j++)
{
String col_name = (String) header_row.get(j) + j;
if (col_name == null || col_name.equalsIgnoreCase(""))
{
continue;
}
// column
IWDTableColumn col = view.createElement(IWDTableColumn.class, col_name);
// header
IWDCaption header = view.createElement(IWDCaption.class, "cap__" + j);
// text view
IWDTextView textView = view.createElement(IWDTextView.class, "text_"+j);
header.setText((String) header_row.get(j));
col.setHeader(header);
textView.bindText(tableInfo.getAttribute(col_name));
col.setTableCellEditor((IWDTextView) textView);
tableUI.addGroupedColumn(col);
}
//bind the Table UI element to the context
tableUI.bindDataSource(tableInfo);
// add the Table UI element to the view container
if (container != null)
container.addChild(tableUI);
}
}
}
catch (Exception e)
{
msgMgr.reportException(e.getLocalizedMessage());
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
9 | |
7 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 |