cancel
Showing results for 
Search instead for 
Did you mean: 

How to delete dynamically created attribute

suresh_krishnamoorthy
Active Contributor
0 Kudos

Hi,

I am creating table dynamically according to no of columns. first time its displaying correctly, second time once i changed the no of columns its throwing error message like:

com.sap.tc.webdynpro.progmodel.context.ContextException: DataNodeInfo(DynamicView.TableNode): duplicate name for attribute name0.

Everytime before creating table i tried following commands.

table.removeAllColumns();

but still i am getting error.

Help me out in this....

Regards

Suresh KB

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

First, verify if you really need to create the context structure dynamically.

If yes, you can only delete all dynamically created context structures at once using IWDContext.reset().

Can you give more details about the use case?

Armin

suresh_krishnamoorthy
Active Contributor
0 Kudos

Hi Armin,

IWDContext.reset() will reset other mapped node also i want to reset only the node where i created the table.

My application scenerio is like :

I have drop down to list no of columns once u clicked the column from the drop down table should create dynamically.Again if i click other no of columns from drop down table should create accordingly.

Structure of my code:

-I Created static a Value Node.

OnAction of drop down :

- Created Value Attributes according to columns.

WDModify():

- Created IWDTable Object

- Created IWDTextView objects.(same number as that of Value Attributes)

- Bind the text property of IWDTextView object to that of the Value attribute.

- Created IWDTableColumn according to columns. (same number as that of Value Attributes)

- setTableCellEditor of the IWDTableColumn object with IWDTextView object.

wdthis.displayRecords();

Inside displayRecords method i am diplaying all records by binding to the table.

Thanks in advance

Regards

Suresh KB

former_member182372
Active Contributor
0 Kudos

Hi Suresh,

Just an idea:

- Create empty model node;

- in onAction create dynamic implementation of ICMIModelClassInfo and "associate" it with your model node (see Valery`s blog /people/valery.silaev/blog/2005/09/09/common-model-interface for more information)

- the rest is the same like you described (UI elements binding and data loading in displayRecords).

Best regards, Maksim Rashchynski.

Answers (2)

Answers (2)

Former Member
0 Kudos

hello,

another question,

when man click the button "delete field" , the Context attribute must be removed.

how do it?

thx

regards

Yaning

Former Member
0 Kudos

API Documentation..

<i>Node infos also provide a mean to dynamically add child nodes (there are different methods for unmapped, mapped and recursive nodes) or attributes (unmapped or mapped, several methods to add attributes automatically from external meta data). You cannot remove such nodes or attributes afterwards, you can only reset the whole context to its initial state via IWDContext.reset(boolean). </i>

So instead.. delete the particular column..

brahmanandam_ausali
Participant
0 Kudos

hi suresh

table.removeAllColumns();

will remove all the columns from the view.

but when u create the context attributes they are already existing. So it is giving the duplicate context exception.

To solve this problem, first delete all the attributes created dynamically. using below code.

wdcontext.node<urnode>().reset(<b>False</b>).

it will delete all the attrbutes created at runtime.

to delete attrbutes created at designtime use.

wdcontext.node<urnode>().reset(<b>True</b>).

Regards

Brahmanandam.A

collections created at design time will be preserved. All dynamically

added nodes and attributes are destroyed from the metadata.<p>

Calling reset(true) is functionally equivalent to calling reset().<p>

suresh_krishnamoorthy
Active Contributor
0 Kudos

Hi Brahmanandam,

I don't have any method like wdcontext.node<urnode>().reset(False) but wdContext.getContext().removeElement() exists.

I solved my problem using the following code:

if(table != null)

{

table.removeAllColumns();

table.destroyAllColumns();

table.destroyHeader();

}

wdContext.getContext().reset();

In wdDoModifyView ->view.resetView();

Thanks for all

Regards

Suresh KB

Former Member
0 Kudos

removeAllColumns() is not needed if you say destroyAllColumns().

Perhaps table.destroy() would have been easiest here.

Armin