DataProvider parameter problem
I have a simple mySQL database with one table (test3) with three field (id,name and address)
I have set up a dropdown list which is bound to "test3" which displayes the names field (value set to id)
I also have a table component which is bound to "test3" with the following prerender and ValueChange methods...
publicvoid prerender(){
try{
test3DataProvider.cursorFirst();
getSessionBean1().getTest3RowSet().setObject(1,test3DataProvider.getValue("test3.id"));
test3DataProvider.refresh();
}catch (Exception e){
error ("Error");
}
}
publicvoid dropDown1_processValueChange(ValueChangeEvent event){
// TODO: Replace with your code
try{
getSessionBean1().getTest3RowSet().setObject(1,dropDown1.getSelected());
test3DataProvider.refresh();
}catch (Exception e){
error ("fubared");
}
}
When I run this application, I get the Parameter 1 not set error but cannot see whats wrong with the code......
Help !
Description: An unhandled exception occurred during the execution of the web application. Please review the following stack trace for more information regarding the error.
Exception Details: org.apache.jasper.JasperException
java.lang.RuntimeException: java.sql.SQLException: No value specified for parameter 1
Possible Source of Error:
Class Name: org.apache.jasper.servlet.JspServletWrapper
File Name: JspServletWrapper.java
Method Name: service
Line Number: 384
Message was edited by:
kyote
[2287 byte] By [
kyotea] at [2007-11-27 7:42:34]

# 4
thanks. I think the problem is related to setting up the paramaterized RowSet query in the session bean....
The query looks like this, the "?" is the parameter part of it and it seems to think this has not been set but I have set it using creator....
SELECT ALL customers.id,
customers.name,
customers.region
FROM customers
WHERE customers.id = ?
I have followed the example...at http://developers.sun.com/jscreator/learning/tutorials/2/databoundcomponents.ht ml
I have checked a few previous posts and there seems to be many similiar problem without any clear resolution
Message was edited by:
kyote
Message was edited by:
kyote
kyotea at 2007-7-12 19:23:27 >

# 5
The following code does not make sense
getSessionBean1().getTest3RowSet().setObject(1,test3DataProvider.getValue("test3.id"));
test3DataProvider is a wrapper for test3RowSet. So, if you have not yet done the query, the test3DataProvider is not going to have any values.
The problem is not with the data providers, it is with your program logic.
I think what you are wanting to do, is to provide all the names, have a person select a name and that specific record in the table.
If so, then you need 2 rowsets, one that gets all the records (no qualifier) and one that has the parameterized query.
Take a look at http://developers.sun.com/jscreator/learning/tutorials/2/databoundcomponents.ht ml. You want to do something like this except that you use the same TABLE for both the drop down list and the table component. Drop the TABLE on the page twice. First drop it on the drop down list, then drop the TABLE on the table component. The second time, a dialog box should appear and select the radio button for creating a new rowset in the session bean. Edit this rowset to add the qualified query.
It might be a good idea to do these 2 tutorials to become comfortable with using parameterized queries and dataproviders and see that they do indeed work.
http://developers.sun.com/jscreator/learning/tutorials/2/databoundcomponents.ht ml
http://developers.sun.com/jscreator/learning/tutorials/2/helloweb.html