cancel
Showing results for 
Search instead for 
Did you mean: 

exception while creating table columns dynamically !

lakshmikanthaiah_s
Participant
0 Kudos

Dear Friends,

I am trying to create columns for a table Dynamically using a loop.

I want to give Column Name in the code below:

column1 = (IWDTableColumn)view.createElement(IWDTableColumn.class, colName);

Giving the column Name is giving exception

com.sap.tc.webdynpro.services.exceptions.WDCreationFailedException: Cannot create view element implementation com.sap.tc.webdynpro.clientserver.uielib.standard.impl.TableColumn

Instead if I use null, it works fine.

As per my requirement, I have to use column name.

Can anybody help me on this.

Many Thanks in Advance.

Lakshmikanthaiah

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Lakshmikanth,

Strore all the column names in a String array called colName and try this code,


for(int i=0; i<colName.length;i++)
{
IWDTableColumn column = (IWDTableColumn) view.createElement(IWDTableColumn.class,"ColCaption" +i );
 
IWDCaption caption = (IWDCaption) view.createElement(IWDCaption.class,"Caption" +i);
 
caption.setText(colName<i>);
column.setHeader((IWDCaption) caption);
 
table.addColumn(column);
}

Regards

Kishan

Former Member
0 Kudos

As per my requirement, I have to use column name.

What does that mean? How can the technical ID of a table column be part of your requirement?

Armin

Former Member
0 Kudos

Hi Lakshmikanth,

Use the following code instead,


IWDTableColumn column = (IWDTableColumn) view.createElement(IWDTableColumn.class,"ColCaption" );

IWDCaption caption = (IWDCaption) view.createElement(IWDCaption.class,"Caption" );

caption.setText(<colName>);
column.setHeader((IWDCaption) caption);

table.addColumn(column);

The above code adds a column named <colName> to the table.

Regards

Kishan

Edited by: kishan chandranna on Jan 6, 2009 5:28 AM

Former Member
0 Kudos

Hi,

if you are writing the below code in a loop

column1 = (IWDTableColumn)view.createElement(IWDTableColumn.class, colName);

that means you are trying to assign same ID to all the columns which is not possible.

An ID is a unique identifier you need to keep the ID for each column different.

Former Member
0 Kudos

That's correct. If you want to rely on implicit personalization, you should assign stable IDs to all UI elements that should be personalizable.

Armin

Former Member
0 Kudos

Hi,

I had seen the following code some where in SDN. I didnot remember the thread. It may be of some usefull for you

// 3. Create Table:

table = (IWDTable)view.createElement(IWDTable.class,"ID");

String[] colHead = {"Master ","Business","Business1"} ;

int count = 0;

IWDTableColumn nameColumn = null;

for (int j = 0; j < 3; j++) {

//4. Create CellEditor (TextView):

//5. Bind attribute to the TextView:

//6. Create Column:

nameColumn = (IWDTableColumn) view.createElement(IWDTableColumn.class, "column"+j);

IWDCaption colHeader = (IWDCaption)view.createElement(IWDCaption.class,"header"+j);

IWDTextView textView = (IWDTextView)view.createElement(IWDTextView.class , "text"+j);

colHeader.setText(colHead[j]);

nameColumn.setHeader(colHeader);

textView.setText("");

textView.bindText(wdContext.getChildNode("TableNode",IWDNode.LEAD_SELECTION).getNodeInfo().getAttribute("name"+j));

//7. Set CellEditor of Column:

nameColumn.setTableCellEditor((IWDTextView)textView);

//8. Add the Column to the Table:

table.addColumn(nameColumn);

Regards

Raghu