on 10-19-2008 7:10 AM
Hi all
i have small requirement as follows.
i have a view in which i have 3 UI elements one is webdynpro form,Table UI element and third one is submit button.
now at runtime when i will enter the details in the form and click on the submit button then those record details has been stored in Table. then next time again when i submit the form with details then the table contains all records of current and existing ...so table has to maintain mutile records thru form via submit form..
i need sample code on the same.
points are always rewardable
Thanks
Sunil
Assume you have three fields in the form: Name, dob and address
First define your context:
at root context: create three attributes
name of type string
dob of type date
address of type string
now for table you must create a node name tNode and copy the same attributes into tNode.
your context should look like this:
context
+ name
+ dob
+ address
+ tNode
+ name
+ dob
+ address
I hope you know how to map context attributes to the table and form elements. now you can put following code in your submit button action:
IPrivate<your view name>.ITNodeElement item = wdContext.createTNodeElement();
item.setName(wdContext.currentContextElement().getName());
item.setDob(wdContext.currentContextElement().getDob());
item.setAddress(wdContext.currentContextElement().getAddress());
wdContext.nodeTNode().addElement(item);
//This will clear your form data
wdContext.currentContextElement().setName("");
wdContext.currentContextElement().setDob(null);
wdContext.currentContextElement().setAddress("");
;
This will show records into UI table as you insert them.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I had worked on same requirement, It is simple just use ArrayLIst.
Let Assume you have three fields Number,Name and Marks. You want to take input of three fields in Form from User and show all the appended values in Table. The following is sample code for that
1) //Declare a ArrayList in Public Part
//@@begin others
ArrayList list=new ArrayList();
//@@end
2) // Under your Action Button do the following code
public void onActionupdate(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//@@begin onActionupdate(ServerEvent)
//Create an Element of node that is pointed to table on each action.
IPrivateExcelviw.IAbcElement ele = wdContext.createAbcElement();
//set the values to your table element getting values from form node
ele.setNo(wdContext.currentAbcElement().getNo());
ele.setName(wdContext.currentAbcElement().getName());
ele.setMarks(wdContext.currentAbcElement().getMarks());
//Add the element to the ArrayList
list.add(ele);
//Invalidate the Form node such that the values in Form will be cleared
wdContext.nodeAbc().invalidate();
//Bind ArrayList to the node that is pointed to Table UI wdContext.nodeAbc().bind(list);
//@@end
}
Here in this example I had used only one node (ABC) for both Form and Table element. Hope you understand this and your requirement is solved. Revert me if you need any clarifications on this.
Regards
Raghu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
For this first you need to create the element for your node using:
node.create<Node Name>Element();
And then add it to the node using:
wdContext.node<Node Name>().addElement();
Hope this helps.
Cheers,
Manoj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi!
you can do that by just using the addElement() method in a action for submit button.
this is a sample code to add records in table.
//create node
IPrivateSDNView.ITableDataNode node = wdContext.nodeTableData();
IPrivateSDNView.ITableDataElement ele = null;
//iterate through table
for(int i=0;i<tableRecords.length;i++)
{
//create table element
ele = node.createTableDataElement();
// set your data to all attributes
ele.setId();
//add element
node.addElement(ele);
}
thanks
vishal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.