cancel
Showing results for 
Search instead for 
Did you mean: 

Set the out put of the Sql table in Table UI element

Former Member
0 Kudos

Hi,

I want to put the value which i retrieve from one SQL table to the Table UI element which i created in application. I have done Create Binding to the table also with context attribute And set the out put of that ResultSet to the particular context element also. Still i am not able to display the value in the table can any one help me Please.

Regards,

H.V.Swathi

Accepted Solutions (1)

Accepted Solutions (1)

nikhil_bose
Active Contributor
0 Kudos

plz post code.

are you filling the context on initialization?

nikhil

Former Member
0 Kudos

Yes i am fillingg it in wdInit() method

CallableStatement cs1=con.prepareCall("{call Usp_TimeSheetList(?,?,'development',0)}");

wdComponentAPI.getMessageManager().reportSuccess("00date");

cs1.setDate(1,date2);

wdComponentAPI.getMessageManager().reportSuccess("00date date"+date2);

cs1.setInt(2,id);

wdComponentAPI.getMessageManager().reportSuccess("00date id"+id);

cs1.execute();

ResultSet rsDate = cs1.executeQuery();

while(rsDate.next())

{

String dateString=rsDate.getString(1);

wdComponentAPI.getMessageManager().reportSuccess("00date"+dateString);

Date today = df.parse(dateString);

wdComponentAPI.getMessageManager().reportSuccess("00date"+today.toString());

java.sql.Date datepass =new java.sql.Date(today.getTime());

wdComponentAPI.getMessageManager().reportSuccess("00date"+datepass.toString());

wdContext.currentPersonalDataElement().setMyDate(datepass);

wdContext.currentPersonalDataElement().setHrsWorked(rsDate.getFloat(7));

wdComponentAPI.getMessageManager().reportSuccess("00date"+rsDate.getFloat(7));

wdContext.currentPersonalDataElement().setHolidays(rsDate.getString(13));

wdComponentAPI.getMessageManager().reportSuccess("00date"+rsDate.getString(13));

}

//String querry="select * from tbltimesheet where Emp_id=? and Tmsht_Submtdate=?";

}

Edited by: H.V Swathi on Jan 12, 2009 12:31 PM

nikhil_bose
Active Contributor
0 Kudos

the following code is to create table node element for each result (row) from database



CallableStatement cs1=con.prepareCall("{call Usp_TimeSheetList(?,?,'development',0)}");
//wdComponentAPI.getMessageManager().reportSuccess("00date");
cs1.setDate(1,date2);
//wdComponentAPI.getMessageManager().reportSuccess("00date date"+date2);
cs1.setInt(2,id);
//wdComponentAPI.getMessageManager().reportSuccess("00date id"+id);
//cs1.execute();
ResultSet rsDate = cs1.executeQuery();
IPrivate<CompName>.IPersonalDataElement pel;
while(rsDate.next())
{

String dateString=rsDate.getString(1);
//wdComponentAPI.getMessageManager().reportSuccess("00date"+dateString);
Date today = df.parse(dateString);
//wdComponentAPI.getMessageManager().reportSuccess("00date"+today.toString());
java.sql.Date datepass =new java.sql.Date(today.getTime());
//wdComponentAPI.getMessageManager().reportSuccess("00date"+datepass.toString());
pel = wdContext.createPersonalDataElement();
pel.setMyDate(datepass);
pel.setHrsWorked(rsDate.getFloat(7));
wdContext.nodePersonalData().addElement( pel);
//wdComponentAPI.getMessageManager().reportSuccess("00date"+rsDate.getFloat(7));
//wdContext.currentPersonalDataElement().setHolidays(rsDate.getString(13));
//wdComponentAPI.getMessageManager().reportSuccess("00date"+rsDate.getString(13));
}
//String querry="select * from tbltimesheet where Emp_id=? and Tmsht_Submtdate=?";
}
}

Edited by: Nikhil Bose on Jan 12, 2009 5:08 PM

Former Member
0 Kudos

Hi nikil,

This code wont change value of the other value attribute write?

I just want to clarify that.

Regards

nikhil_bose
Active Contributor
0 Kudos

This code does filling the table for each row from resultset.

try to uncomment or you can add new logic accordingly.

nikhil

Former Member
0 Kudos

It is filling only null value to the attribute.

When i tried to print the context value after setting it. It is giving null value.

Regards,

H.V.Swathi

nikhil_bose
Active Contributor
0 Kudos

plz try printingafter adding the element to node.

I'm not sure about other things like

what rsDate.getString(1) prints?

which message you are printing in SQLException ?

hope you are getting the valid resultset.

nikhil

Former Member
0 Kudos

Hi,

I am able to fetch the data through this code only only the last row can be placed in the table.

code is

String dateString=rsDate.getString(1);
								wdComponentAPI.getMessageManager().reportSuccess("dateString"+dateString);	
								Date today = df.parse(dateString);	
								wdComponentAPI.getMessageManager().reportSuccess("today.toString()"+today.toString());						
								java.sql.Date datepass =new java.sql.Date(today.getTime()); 
								wdComponentAPI.getMessageManager().reportSuccess("datepass.toString()"+datepass.toString());
								wdContext.currentPersonalDataElement().setMyDate(datepass);
								wdComponentAPI.getMessageManager().reportSuccess("getMyDate11111"+wdContext.currentPersonalDataElement().getMyDate());
								wdContext.currentPersonalDataElement().setHrsWorked(rsDate.getFloat(7));
								wdComponentAPI.getMessageManager().reportSuccess("getHrsWorked1111"+wdContext.currentPersonalDataElement().getHrsWorked());
								wdContext.currentPersonalDataElement().setHolidays(rsDate.getString(13));
								wdComponentAPI.getMessageManager().reportSuccess("getHolidays"+wdContext.currentPersonalDataElement().getHolidays());

Do i need to put this in any for loop.

can any one help me in this.

Regards,

H.V.Swathi

Edited by: H.V Swathi on Jan 12, 2009 1:44 PM

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Swathi,

Have you checked you are getting Values from ResultSet by printing the Values.

If yes then please check the steps to assign the result of resultset to the table columns.

1. you can add the resultset value to array List.

2. create the object of Table Node like

IPrivateTestTaxonomyView.IVn_LastLevelElement ele=null;

3.Now inside a for loop which is from zero to size of arraylist initialize the table node like ele = wdContext.nodeVn_LastLevel().createVn_LastLevelElement();

4. Now you can set the values fropm the arraylist to table columns like.

for(int j=0;j<abc.size();j++){
			ele = wdContext.nodeVn_LastLevel().createVn_LastLevelElement();

			
			ele .setVa_Column1(abc.get(j).toString());
ele .setVa_Column2(abc.get(j).toString());

			wdContext.nodeVn_LastLevel().nodeVn_Attributes().addElement(ele );
			}

Regards

Narendra