cancel
Showing results for 
Search instead for 
Did you mean: 

IWDTable.destroyAllColumns() does not seem to work

ChrisPaine
Active Contributor
0 Kudos

Hello,

I've just come across a bit of a problem with the destroyAllColumns() method of the interface IWDTable.

I've used this method successfully before to dynamically build tables based on user selections. But since having updated my system to SP18, I've started to have some problems...

I'm getting a dump:

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

at com.sap.tc.webdynpro.progmodel.view.ViewElementFactory.createElement(ViewElementFactory.java:75)

at com.sap.tc.webdynpro.progmodel.view.View.createElement(View.java:89)

at com.wombling.uitest.TestView.wdDoModifyView(TestView.java:179)

I built a very simple application to test the issue - my idea - dynamically create a table column, then remove it using the destroyAllColumns method, then try to create it again (I know you'd never do this in a real situation in the same method - my issue in my real application occur when the method is called a second time)

Here's the content of my wdDoModifyView method...

IWDTable myTable = (IWDTable) view.getElement("Table");

		myTable.destroyAllColumns();

		IWDTableColumn col =
			(IWDTableColumn) view.createElement(
				IWDTableColumn.class,
				"Test_Col");

		IWDCaption cap1 =
			(IWDCaption) view.createElement(IWDCaption.class, "Test_Caption");

		IWDTextView cell1 =
			(IWDTextView) view.createElement(IWDTextView.class, "Test_Cell");

		cell1.setHAlign(WDInputFieldAlignment.FORCED_LEFT);

		cell1.bindText(wdContext.nodeTest().getNodeInfo().getAttribute("Test"));

		IWDTableCellEditor editor1 = (IWDTableCellEditor) cell1;
		cap1.setText("My New table col");

		col.setTableCellEditor(editor1);
		col.setHeader(cap1);

		// exact same code!		
		myTable = (IWDTable) view.getElement("Table");

		myTable.destroyAllColumns();

/* this very next line is the one that will cause a dump - even though it shouldn't
 *because the column that the system is saying already exists - should have been
  *deleted by the previous destroyAllColumns() method!
*/
		col =
			(IWDTableColumn) view.createElement(
				IWDTableColumn.class,
				"Test_Col");

		cap1 =
			(IWDCaption) view.createElement(IWDCaption.class, "Test_Caption");

		cell1 =
			(IWDTextView) view.createElement(IWDTextView.class, "Test_Cell");

		cell1.setHAlign(WDInputFieldAlignment.FORCED_LEFT);

		cell1.bindText(wdContext.nodeTest().getNodeInfo().getAttribute("Test"));

		editor1 = (IWDTableCellEditor) cell1;
		cap1.setText("My New table col");

		col.setTableCellEditor(editor1);
		col.setHeader(cap1);

Pretty simple really - and very easy to replicate - a simple application with a single view with a single node - "Test" with a single attribute "Test", a single table created in the view with an id of "Table", which is bound to the context node... and the above as the only code...

What's going on? I've used this exact same code in SP15 (NW04) and not had any issues? is there something else that I need to do now to remove the reference to the column?

Please help me!

Many thanks,

Chris

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

The problem is the following:

You create a TableColumn with ID "Test-Col" but you don't add it to the table's column collection.

Then you call table.destroyAllColumns() which doesn't destroy the created column because it has not been added to the table.

The next creation of the column fails because the ID has already been used (but I wonder why the exception does not says "Duplicate ID...". I have to check the code for this).

Armin

ChrisPaine
Active Contributor
0 Kudos

Armin,

Thanks - that was so obvious it should have hit me like grand piano falling off a large building...

Thanks for your help!

Now I just have to figure out why it's not doing the same thing in my application - where the I navigate back to the same view I'm getting this same error - even though I'm pretty sure I've added the column to the table - and the next time destroyed it before I rebuild... Darn FPM makes everything more complex

Many many thanks,

Chris

Answers (1)

Answers (1)

Former Member
0 Kudos

I think this method is depricated.

Try using destroyAllGroupedColumns();

Regards, ANilkumar

ChrisPaine
Active Contributor
0 Kudos

Hmm - this is NW04 SP18 - no such method as destroyAllGroupedColumns()...

I have from IWDTable - destroyAllColumns()

destroyHeader()

destroyMasterColumn()

destroyToolBar().

Possibly depreciated in NW04s... but I'm still struggling in good ole NW04.

Any other suggestions?

Thanks!

Former Member
0 Kudos

Oh...I am sorry...I thought you are using NW04s !!!

-Anilkumar

ChrisPaine
Active Contributor
0 Kudos

No worries (as we say here in Australia).

I wasn't very clear about that above. Definately on a NW04 system here. Thanks for the suggestion even though.

Thanks,

Chris

Former Member
0 Kudos

Hi,

Try using "null" instead of explicitly mentioning the UI id.


IWDTableColumn col =
			(IWDTableColumn) view.createElement(
				IWDTableColumn.class,
				null);

Regards

Bharathwaj