Skip to Content

Data not pipulating into table

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 21, 2008 at 01:39 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 21, 2008 at 01:46 PM

    Connection is working fine.

    I think probmelm is with WDDOINIT code

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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.

  • Posted on Jan 21, 2008 at 02:19 PM

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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.