Skip to Content
author's profile photo Former Member
Former Member

Basic TableUI element to Retrieve Data from DB in WEbDynPro For Java

Hi Experts,

I am new to WebDynPro for java.Can any body please help me out from this issue.

I am trying to display records from DataBase by Using Table UI element.

DBTable Contains 10 rows.

I have created a Node and Attributes(for every column) .

I am using JDBC code to retrieve data from database and assigning to Attributes.

But in Table UIElement its displaying only last record from database as first row in UIElement.

Its over writing previous rows.

Can any body please help me the correct procedure to retrieve data from DataBase.

Thanks and Regards,

Shashikiran.B

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Apr 02, 2008 at 12:13 PM

    hai shashi,

    There is no need to create seperate nodes for each column.All you have to do is create a node(table) and create as many attributes with respect to columns.For instance if you have 3 columns in the table create 3 attributes under that node(table) say attribute a,b,c.Now go to the properties of table and in the datasource property of table choose the table node from the context so that the data is binded.Now just follow the following code

    for(int i=0;i<table in db.size();i++)

    {

    wdcontext.nodetable.seta(field in the database table to be set here)

    wdcontext.nodetable.setb()

    ..

    }

    Try this ...Any issues let me know..

    Thanks n Regards

    Sharanya.R

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 02, 2008 at 12:09 PM

    Hi,

    Iterate through the result set object

    populate the context node

    Ex:Replace the context nodeName with that of yours.

    ResultSet resultSet = stmt.getResultSet();
    	  //Iterate through the resultset
    	  while(resultSet.next())
    	  {
    		  //Create element of the context node
    		 IWDNodeElement nodeElement = wdContext.nodeOrders().createElement();
    		 //assign value from the database to the context attribute
    		 //Replace attributeName with your attribute name
    		 //Replace value with resultSet.getShort("<ColumnName>")
    		 nodeElement.setAttributeValue(attributeName, value);
    		 //Add the element to your node
    		 wdContext.nodeOrders().addElement(nodeElement);
    	  }
    

    Regards

    Ayyapparaj

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 02, 2008 at 12:08 PM

    Hi,

    you better post your code populating the webdynpro node.I guess you are not doing the

    nodeXX.addElement(element);

    inside the for loop

    Regards,

    Sudhir

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Ayyapparaj,

      Thanks for your quick response.

      I tried by replacing following code in your code snippet.

      while(rs.next()) {

      IWDNodeElement nodeElement = wdContext.nodeEmpDetails().createElement();

      nodeElement.setAttributeValue(SNo, rs.getString(1));

      wdContext.nodeEmpDetails().addElement(nodeElement);

      }

      but its showing error at SNo which is my Context attribute element.

      Can you please help me how should i put my Context attribute in your code snippet.

      And more over i have to display 5 columns so

      should i create 5 elements by using above code.

      Can you please Help me as soon as possible.

      Thanks in advance

      Regards,

      Shashikiran.

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.