cancel
Showing results for 
Search instead for 
Did you mean: 

display values from a Result Set to a table in Webdypro!!!!

Former Member
0 Kudos

Hi all,

Can anybody tell me how can I display values to a Table? I've already designed the table UI which has 4 columns.I'm trying to get the data from the database and display it in the table row by row.Please help me with the code.

Thanks,

Shiny

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi all,

Initially i had 2 views. First view is juz a text to get the input. I'm sending this value to the next view which has a table to display a set of values from a resultset queried based on the input value.

Now I need to have only one view. when i click the button, the table with the should be displayed below in the same view. Can anybody give an idea????

Thanks,

Shiny

suresh_krishnamoorthy
Active Contributor
0 Kudos

Hi Shiny,

You can acheive by Visiblity..

You can create a valueAttribute say tableVisibility (of type com.sap.ide.webdynpro.uielementdefinitions.Visibility) and bind it to the 'visible' property of the table.

Initially, set the tableVisibility to NONE.

wdContext.currentContextElement().setTableVisibility(WDVisibility.NONE);

Onclick button action you set the visibility of the table to "VISIBLE" using the contextelement (=tableVisibility)

wdContext.currentContextElement().setTableVisibility(WDVisibility.VISIBLE);

Regards, Suresh KB

sid_sunny
Contributor
0 Kudos

Hi Shiny,

it makes no difference you can do it in the same view too.

Regards

Sid

Former Member
0 Kudos

Sid,

Wat i need is initially only the text box n the button should be visible. After the value is entered , the table should be dispalyed blew.

Actually , how will I hide the table initially and how will i enable it after the button click ????

Thanks,

Shiny

Former Member
0 Kudos

Hi,

in the init of the view set the visiblilty of the table as NONE. then on button click, set it as VISIBLE.

for this u'll need to create a context element of type visibility and set that to the table's visibility property..

regards

prasy

Former Member
0 Kudos

Thanks a ton suresh..It worked.... But sorry i'm not able to reward u points for this......

Answers (5)

Answers (5)

Former Member
0 Kudos

Thanks a lot everybody....It worked...

Former Member
0 Kudos

Hi Shiny,

First create context mapping from model to Component controller and from component controller to view controller context.

Now go to view layout.

In the outline tab right click on the transparent container and choose apply template.

In the template choose table and click next.

You can see all the nodes and attributes.

Choose the attributes you want to display in the table.

Hope this will solve your problem.

Former Member
0 Kudos

Hi Suresh & Omri,

Thanks a lot.It helped but only one value is getting displayed in the table. But there are lots of data in the resultset. Please help

Thanks,

Shiny

Former Member
0 Kudos

Hi,

try this code...

int n = wdContext.nodeDB().size();

Suppose the node from database is DB has attibutes No and Name. and the value node has two attributeas A and B.

IPrivateViewname.IDBNode dbnode = wdContext.DB();

IPrivateViewName.IValueNode node = wdContext.nodeValue();

IPrivateViewName.IValueElement ele;

for (int k = 0 ; k < n ; k++)

{

ele = node.createValueElement();

ele.setA(dbnode.getDBElementAt(k).getNo());

ele.setB(dbnode.getDBElementAt(k).getName());

wdContext.nodeValue().addElement(ele);

}

Hope this works....

Regards

Prasy

sid_sunny
Contributor
0 Kudos

Hi Shiny,

Try printing the sizes of resultset and the table datsource node in your view and see whether the two are same or not.

wdComponentAPI.getMessageManager.reportSuccess("Size of resultset is "resultset.size()" and the size of table data source node is "+wdContext.nodeTableSource().size());

Regards

Sid

former_member182374
Active Contributor
0 Kudos

Hi,

Define a value node in the context. Call it 'data'

data will have 4 value attributes: field1, field2, field3 & field4

The fields from the DB are called f1, f2, f3 & f4

Now, do something like this:

IPrivate<view name>.IDataNode node = wdContext.nodeData();

IPrivate<view name>.IDataElement elem = null;

while (rs.next) {

elem = node.createDataElement();

elem.setField1(rs.getString("f1"));

elem.setField2(rs.getString("f2"));

elem.setField3(rs.getString("f3"));

elem.setField4(rs.getString("f4"));

node.addElement(elem);

}

Omri

suresh_krishnamoorthy
Active Contributor
0 Kudos

Hi Shiny,

Try like this

Create Value Node Table under that create A,B,C,D context value attribute bind to table UI element.

Fetch the data from Database and set to the table context attibute

for(int i=0 ; i<nodesize ; i++) {

IPrivateView.ITableElement element = wdContext.createTableElement();

element.setA(A);

element.setB(B);

element.setC(C);

element.setD(D);

wdContext.nodeTable().addElement(element);

}

Regards, Suresh KB