cancel
Showing results for 
Search instead for 
Did you mean: 

Not able to add a record into Table created in Web Dynpro java application

Former Member
0 Kudos

Dear All,

While creating a table, I have selected a context node and its attributes to be bound to this table.The properties of this context node are mentioned below

cardinality : 1..n

collectionType : list

selection 1..n

singleton false

typedAccessRequired true.

But in the Table created I not able to add/edit more than 1 row.

Would really appreciate if some 1 would help me out here

Edited by: Roshan N on Jun 26, 2008 6:58 AM

Accepted Solutions (1)

Accepted Solutions (1)

nikhil_bose
Active Contributor
0 Kudos

why do you keeping singleton to false? set it to default value true

Singleton:

property determines the parent-child relation.

if true: for each parent element, there is one child (i.e. 1 - 1)

if false: irrespective of parent, there is only one child ( Many to one).

nikhil

Edited by: Nikhil ßos on Jun 26, 2008 11:00 AM

Former Member
0 Kudos

Nikhil,

In my case i need the parent child relationship to be 1-many.How should I go about doing that?

nikhil_bose
Active Contributor
0 Kudos

make singleton to true. it will work

Actually there is a correction in my previous post.

if singleton is true it is 1 - Many.

nikhil

Edited by: Nikhil ßos on Jun 26, 2008 4:43 PM

Former Member
0 Kudos

Nikhil,

that hasnt worked.Do I have to change any table properties

which are currently set as below

compatibilityMode auto

dataSource Task

design standard

enabled true

firstVisibleRow 0

firstVisibleScrollableCol

fixedTableLayout false

footerVisible true

gridMode both

readOnly false

rowSelectable true

scrollableColCount -1

selectedPopin

selectionChangeBehaviour auto

selectionMode auto

visible visible

visibleRowCount 10

regards,

Roshan

nikhil_bose
Active Contributor
0 Kudos

There is no manual settings needed. Its quite straight-forward.

1) create a node TableNode. don't change default values

2) add attribute Name of type string.

1)place a table UI element in the view

2) bind data source property

3) create a table column and table cell editor as textview

4) bind value to TableNode-Name

now, we will populate some values.

in the wdDoInit() place the code


IPrivate<YourCompName>View.ITableNodeElement   element;
String values[]={"One","Two","Three","Four"};
for( int i = 0; i<values.length; i++) {
  element = wdContext.createTableNodeElement();
  element.setName(values<i>);
  wdContext.nodeTableNode().addElement(element);
}

nikhil

Former Member
0 Kudos

hi try this code.cardinality 0.n

IPrivateFormView.ITableElement ele=wdContext.createTableElement();

ele.setId(wdContext.currentContextElement().get<valueattr>());

ele.setName(wdContext.currentContextElement().get<valattr());

ele.setSalary(wdContext.currentContextElement().getvalattr());

int size = wdContext.nodeTable().size();

for(int i=0;i<size;i++)

{

if(wdContext.currentContextElement().getId()==wdContext.nodeTable().getTableElementAt(i).getId())

{

wdComponentAPI.getMessageManager().reportWarning("record already inserted");

return;

}

}

wdContext.nodeTable().addElement(ele);

wdComponentAPI.getMessageManager().reportSuccess("record suceefully installed");

Thanks if helpful give me points

No new information but asking for points...

Answers (3)

Answers (3)

Former Member
0 Kudos

Rows in the table are created from elements in the context node. You have defined the cardinality of the context node as 1:n, this will give you one element automatically. To get more elements (rows) you have to create and add elements to the node using code like


I<YourNode>Element e = wdContext.node<YourNode>.createAndAdd<YourNode>Element();
e.setXYZ(value);

Armin

former_member197348
Active Contributor
0 Kudos

Hi Roshan,

Change the properties like this and try:

cardinality : 0..n

collectionType : list

selection 0..n

singleton true

typedAccessRequired true.

Your problem is to add the elements to this node, I guess you are taking input from the table UI element. Then you must create elements to this node.

IPrivate<viewname>.I<nodename>node node = wdContext.node<nodename>();
for(int i=0; *i<10* ; i++)
{
IPrivate<viewname>.I<nodename>Element ele = node.create<nodename>Element();
//If you want you can set you attributes here
node.addElement(ele);
}

10 elements are created.

You can create & add elements like this.

Regards,

Siva

PradeepBondla
Active Contributor
0 Kudos

Hi,

Try with changing the cardinality.

if you put the code you are using, it will be helpful to findout

regards,

Pradeep

Former Member
0 Kudos

Pradeep,

I did change the cardinality but that hasnt worked.I havent coded anything as of now, all changes in the setting are being made in the SAP netweaver development studio.The coding part i would look into later, where i need to put in my business logic.I am doing a POC on Web Dynpro bacis features, without considering the ABAP part.

Thanks for the reply mate