cancel
Showing results for 
Search instead for 
Did you mean: 

Data not pipulating into table

lokesh_kamana
Active Contributor
0 Kudos

Hi sdns,

i have dreated 2 classes:- 1)main

2)sub

<h5>code of main:-</h5>

public class main {

Collection plist = new ArrayList();

Connection conn = null;

Statement st;

public void get_details()

{

try

{

Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");

conn = DriverManager.getConnection( "jdbc:microsoft:sqlserver://10.10.30.25:1433;databaseName=TrackingSystem","sa","sa" ) ;

st = conn.createStatement();

String str = "select * from [Project Table]";

ResultSet rs = st.executeQuery(str);

String a = rs.getString(1);

String b = rs.getString(2);

String c = rs.getString(3);

while(rs.next())

{

pdetails rec = new pdetails();

rec.setEname(a);

rec.setRname(b);

rec.setDid(c);

plist.add(rec);

}

}

catch(Exception e)

{

}

}

public Collection getPlist() {

return plist;

}

public void setPlist(Collection collection) {

plist = collection;

}

}

<h3>code of pdetails</h3>

public class pdetails {

private String Ename;

private String Rname;

private String Did;

public pdetails()

{

Ename = new String();

Rname = new String();

Did = new String();

}

public pdetails(String Ename,String Rname,String Did)

{

this.Ename = Ename;

this.Rname = Rname;

this.Did = Did;

}

public String getDid() {

return Did;

}

public String getEname() {

return Ename;

}

public String getRname() {

return Rname;

}

public void setDid(String string) {

Did = string;

}

public void setEname(String string) {

Ename = string;

}

public void setRname(String string) {

Rname = string;

}

}

I have created a jar file for this classes And imported as a model in my web Dynpro Application.

And mapped it to component controller.

And from there to view controller.

I had a view with a table .

I created the table by using template of table.

And Binded it to the context of the view.

And the code i have written in the WDDOINIT() method is:-

IWDMessageManager msg = wdComponentAPI.getMessageManager();

try

{

Collection c;

c= new ArrayList();

main m = new main();

m.get_details();

c = m.getPlist();

wdContext.nodePdetails().bind(c);

wdContext.nodePdetails().invalidate();

}

}

catch (Exception e) {

// TODO: handle exception

msg.reportWarning("Sorry");

}

But data is not getting populated in my table.Anything i have to add to my code.

Or else have i done anything wrong in my code

Please help me in this Regard.

Accepted Solutions (0)

Answers (3)

Answers (3)

lokesh_kamana
Active Contributor
0 Kudos

If u dont mind can u tell me what that something means

lokesh_kamana
Active Contributor
0 Kudos

Connection is working fine.

I think probmelm is with WDDOINIT code

Former Member
0 Kudos

wdContext.nodePdetails().bind(c);

wdContext.nodePdetails().invalidate();

Instead of this try somthing like this:

for (int i=0; i<c.size(); i++) {

SomeObject o = (SomeObject) c.get(i);

PdetailsElement e = wdContext.nodePdetails.createPdetailsElement();

e.setPropA(c.getPropA());

etc.

wdContext.nodePdetails.add(e);

}

Good luck.

Former Member
0 Kudos

What I mean is replace these 2 lines:

wdContext.nodePdetails().bind(c);

wdContext.nodePdetails().invalidate();

with this code:

wdContext.nodePdetails().invalidate(); // erase previous search results

for (int i=0; i<c.size(); i++) { //iterate

SomeObject o = (SomeObject) c.get(i); // store record in temp variable

PdetailsElement e = wdContext.nodePdetails.createPdetailsElement(); //create context element

e.setPropA(o.getPropA()); // set properties of context element

etc. // set properties of context element

wdContext.nodePdetails.add(e); // add context element to context node

}

I assume that you have bound the table to nodePdetails, andt that this node has cardinality 0..n.

Also, the elements of this node contain the 3 strings that you want to display in the table.

So when you iterate over the collection that is the result of your query,

you create a new element of the context structure (Pdetail) and set the 3 string values.

Finally add each context element that was created to the context node (add).

Hope this helps, good luck.

Former Member
0 Kudos

Hi,

Have you defined a JDBC connector in the Visual Administrator?

I believe this is required.

Can you print out or log the number of records you fetch? Then you know whether the problem is in your JDBC configuration (0 results) of in the WD framework ().

Good luck,

Roelof