Trouble updating the database

Hi,

I using java studio creator 2 update 1. I have two pages. The first page contains a table with hyperlinks in serial_no column. When the user clicks on a hyperlink(serial_no) it redirects to another page which displays the details of the product that can be edited as drop down lists and text areas. I am not able to update the database with the edited values. I have been struggling with this since a week. Please help me. The code in the second page is as follows

public void prerender() {

serialNo = (String)getExternalContext().getRequestParameterMap().get("SerialNo");

try

{

getSessionBean1().getTblSampleRowSet4().setCommand("select Username, Problem_Type, Priority , Enhancement, Time, Source_req, Assigned_To,substring_index(Comment,'<END>',-1) as 'userComment', Solution, serial_no from tblSample where serial_no = " + serialNo);

stUserName.setText(getSessionBean1().getTblSampleRowSet4().getString("Username" ));

ddlProblemType.setSelected(getSessionBean1().getTblSampleRowSet4().getString("P roblem_Type"));

String priority = getSessionBean1().getTblSampeRowSet4().getString("Priority");

outputText1.setValue(priority);

ddlPriority.setSelected(getSessionBean1().getTblSampleRowSet4().getString("Prio rity"));

// ddlp.setSelected(getSessionBean1().getTblSampleRowSet4().getString("Priority")) ;

ddlEnhancement.setSelected(getSessionBean1().getTblSampleRowSet4().getString("E nhancement"));

ddlTime.setSelected(getSessionBean1().getTblSampleRowSet4().getString("Time"));

ddlSourceReq.setSelected(getSessionBean1().getTblSampleRowSet4().getString("Sou rce_req"));

ddlAssignedTo.setSelected(getSessionBean1().getTblSampleRowSet4().getString("As signed_To"));

taSolution.setText(getSessionBean1().getTblSampleRowSet4().getString("Solution" ));

taUserComment.setText(getSessionBean1().getTblSampleRowSet4().getString("userCo mment"));

}

catch(Exception e)

{

}

//}

}

}

/**

*

Callback method that is called after rendering is completed for

* this request, if <code>init()</code> was called (regardless of whether

* or not this was the page that was actually rendered). Customize this

* method to release resources acquired in the <code>init()</code>,

* <code>preprocess()</code>, or <code>prerender()</code> methods (or

* acquired during execution of an event handler).

*/

public void destroy() {

tblSampleDataProvider4.close();

// tblSampleDataProvider.close();

}

public String btnSave_action() {

// TODO: Process the button click action. Return value is a navigation

// case name where null will return to the same page.

try {

tblSampleDataProvider4.setValue("tblSample.Problem_Type", ddlProblemType.getSelected());

tblSampleDataProvider4.setValue("tblSample.Priority", ddlPriority.getSelected());

tblSampleDataProvider4.setValue("tblSample.Enhancement", ddlEnhancement.getSelected());

tblSampleDataProvider4.setValue("tblSample.Time", ddlTime.getSelected());

tblSampleDataProvider4.setValue("tblSample.Source_req", ddlSourceReq.getSelected());

tblSampleDataProvider4.setValue("tblSample.Assigned_To",ddlAssignedTo.getSelect ed());

tblSampleDataProvider4.setValue("tblSample.Comment",taUserComment.getText());

tblSampleDataProvider4.setValue("tblSample.Solution", taSolution.getText());

tblSampleDataProvider4.commitChanges();

tblSampleDataProvider4.refresh();

} catch (Exception ex) {

outputText1.setValue("error");

}

return null;

}

If i use

getSessionBean1().getTblSampleRowSet4().execute(); after setting the command, it doesnt work. But if i comment it out, data corresponding to the serial no passes gets displayed. But I am not able to update the table with edited data.

S

[4023 byte] By [spotineni] at [2007-11-26 8:35:53]
# 1

Just a quick comment--

You won't need rowset.getString(..) and dataprovider.setValue(...) if you bind the components and it could make it much simpler.

There's a step by step tutorial on how to achieve this:

http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/ins erts_updates_deletes.html

If you can zip up the Project and email to me at CreatorFeedback AT sun DOT com, i can take a quick look at it. I would need your schema/SQL script as well.

HTH,

Sakthi

sakthivelgopal at 2007-7-6 22:05:46 > top of Java-index,Development Tools,Java Tools...
# 2
Also, you could refer to the "Single Page CRUD with Form" - a bundled sample app which has implemented this type of scenario.To create a copy of this app, Choose> File> New Project> Samples> Saingle Page CRUD with Form and click Finish.-Sakthi
sakthivelgopal at 2007-7-6 22:05:46 > top of Java-index,Development Tools,Java Tools...
# 3
(Sadly the updates section of this article is absent, but there are sample apps to be found)
Zeezoo at 2007-7-6 22:05:46 > top of Java-index,Development Tools,Java Tools...
# 4
Implementing the 'Save' feature does the UPDATE to the database . This statement generates SQL for Updates to database: tripDataProvider.commitChanges(); http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/ins erts_updates_deletes.html#03-Sakthi
sakthivelgopal at 2007-7-6 22:05:46 > top of Java-index,Development Tools,Java Tools...
# 5

Thanks a lot Sakthi..It worked. But i have one more question. Is there any sample code I can refer to to implement the functionality of clicking/double clicking on a particular cell of the table to make it editable and then after editing changing it again to static text. The sample code in the tutorials shows it but with an edit checkbox.

Thanks,

S

spotineni at 2007-7-6 22:05:46 > top of Java-index,Development Tools,Java Tools...
# 6
hi, i having the same problem with updating but wen i click the update button, it gave me this error. System Messages* java.lang.IllegalArgumentException: argument type mismatchhow do i solve this? please help me as i been struggling very long to find a solution.
@18@ at 2007-7-6 22:05:46 > top of Java-index,Development Tools,Java Tools...