on 08-18-2008 12:31 PM
Hi Experts,
I am New to java Webdynpro.I want to know,"how to populate a tableUI element through code with more than 1 row.I could display 1 row.I am unable to bind data for more than 1 row.Should i create seperate elements for each row and bind each element to the context node.Please help me in solving this issue.
Hi
to add more than one recoed in the table
wat we do is create an array
decalare this array at the end that is
/*
* The following code section can be used for any Java code that is
* not to be visible to other controllers/views or that contains constructs
* currently not supported directly by Web Dynpro (such as inner classes or
* member variables etc.). </p>
*
* Note: The content of this section is in no way managed/controlled
* by the Web Dynpro Designtime or the Web Dynpro Runtime.
*/
//@@begin others
//this is the array used in the program
String emp[][]=
{
{"nikhil","tapkir","pune"},
{ "juhi","bhatnagar","delhi"},
};
//@@end
}
i have to insert the above information in a table wid columns firstname lastname and city .
u need to use the for loop to insert the data in the table for more than 1 record
code the following thing in wd init
here fname lname and city are my value attributes mapped to my table columns.
for (int i=0;i<emp.length;i++)
{
IPrivateTabappView.ITablenodeElement tnode=wdContext.createTablenodeElement();
tnode.setFname(this.emp<i>[0]);
tnode.setLname(this.emp<i>[1]);
tnode.setCity(this.emp<i>[2]);
wdContext.nodeTablenode().addElement(tnode);
}
i hope this is what ur doubt was if not pls clarify.
hope this helps u.
Edited by: Nikhil Tapkir on Aug 18, 2008 1:43 PM
Edited by: Nikhil Tapkir on Aug 18, 2008 2:23 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Hema,
To populate a table with multiple rows please use the following piece of code:
For example: Consider that the value node DataNode having two attributes A and B is bound to the DataSource property of your Table UI Element.
IDataNodeElement objDataNode = null;
ArrayList arlDataNode = null;
int size = 0;
size = <No. of rows that you want in the table>;
arlDataNode = new ArrayList();
for(int i=0;i<size;i++)
{
objDataNode = wdContext.createDataNodeElement();
objDataNode.setA(<Set some values>);
objDataNode.setB(<Set some values>);
arlDataNode.add(objDataNode);
}
wdContext.nodeDataNode.bind(arlDataNode);
Hope this of help to you.
Regards,
Tahzeeb.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi
You have to create nodeelement for each row,to fill the values in each row of a table.
and bind this element to the node.
Try this simple code.
node-->Person
attributes-->Fname
Lname
Number
for(int i=0;i<nodePerson().size();i++)
{
IPrivateFirstCompView.IPersonElement pelem=wdContext.nodePerson().createPersonElement();
pelem.setFname("fname"+i);
pelem.setLname("lname"+i);
pelem.setNumber(i);
wdContext.nodePerson().addElement(pelem);
}
or you can get the values from inputfields in a view and set to the table.
Regards
sowmya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
IPrivate<ur view name>View.I<Node Name>Node i<Node Name>Node = wdContext.node<Node Name>();
IPrivate<ur view name>View.I<Node Name>GridElement i<Node Name>Element ;
for(int i=0;i<10;i++){
i<Node Name>Node.create<Node Name>Element();
i<Node Name>Element .set<Your Attribute>("value"+i);
i<Node Name>Node.addElement(i<Node Name>Element );
i<Node Name>Node.moveNext();
}
thanks,
ramesh
Edited by: Ramesh Babu V on Aug 18, 2008 5:29 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
May be of use for you
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.