Hi I have a problem. Can somebody help me. I have done the jsp tutorial in Ultradev 4 and cannot diplay the detail page. I get an error saying no data found. Everything else works besides that.
//set the number of rows displayed on this page
if (Details_numRows == 0) {
Details_numRows = 1;
}
%>
<% String MM_paramName = ""; %>
<%
// *** Move To Record and Go To Record: declare variables
ResultSet MM_rs = Details;
int MM_rsCount = Details_total;
int MM_size = Details_numRows;
String MM_uniqueCol = "EMPLOYEEID";
MM_paramName = "id";
int MM_offset = 0;
boolean MM_atTotal = false;
boolean MM_paramIsDefined = (MM_paramName.length() != 0 && request.getParameter(MM_paramName) != null);
%>
<%
// *** Move To Specific Record: handle detail parameter
if (MM_paramIsDefined && MM_rsCount != 0) {
// get the value of the parameter
String param = request.getParameter(MM_paramName);
// find the record with the unique column value equal to the parameter value
String colVal;
while (Details_hasData) {
colVal = ((MM_rs.getObject(MM_uniqueCol)!=null)?MM_rs.getObject(MM_uniqueCol).toString():""
if (colVal.equals(param)) break;
Details_hasData = MM_rs.next();
MM_offset++;
}
// if not found, set the number of records and reset the cursor
if (!Details_hasData) {
if (MM_rsCount < 0) MM_rsCount = MM_offset;
if (MM_size < 0 || MM_size > MM_rsCount) MM_size = MM_rsCount;
MM_offset = 0;
// reset the cursor to the beginning
Details.close();
Details = StatementDetails.executeQuery();
Details_hasData = Details.next();
MM_rs = Details;
}
}
%>
<%
// *** Move To Record: if we dont know the record count, check the display range
if (MM_rsCount == -1) {
// walk to the end of the display range for this page
int i;
for (i=MM_offset; Details_hasData && (MM_size < 0 || i < MM_offset + MM_size); i++) {
Details_hasData = MM_rs.next();
}
// if we walked off the end of the recordset, set MM_rsCount and MM_size
if (!Details_hasData) {
MM_rsCount = i;
if (MM_size < 0 || MM_size > MM_rsCount) MM_size = MM_rsCount;
}
// if we walked off the end, set the offset based on page size
if (!Details_hasData && !MM_paramIsDefined) {
if (MM_offset > MM_rsCount - MM_size || MM_offset == -1) { //check if past end or last
if (MM_rsCount % MM_size != 0) //last page has less records than MM_size
MM_offset = MM_rsCount - MM_rsCount % MM_size;
else
MM_offset = MM_rsCount - MM_size;
}
}
// reset the cursor to the beginning
Details.close();
Details = StatementDetails.executeQuery();
Details_hasData = Details.next();
MM_rs = Details;
// move the cursor to the selected record
for (i=0; Details_hasData && i < MM_offset; i++) {
Details_hasData = MM_rs.next();
}
}
%>
<%
// *** Move To Record: update recordset stats
// set the first and last displayed record
Details_first = MM_offset + 1;
Details_last = MM_offset + MM_size;
if (MM_rsCount != -1) {
Details_first = Math.min(Details_first, MM_rsCount);
Details_last = Math.min(Details_last, MM_rsCount);
}
[ul][li]Is the field you are trying to compare really called EMPLOYEEID?
[/li][li]Try at the point...
// find the record with the unique column value equal to the parameter value
...to output some values (like the currently searched record and the comparison value). You can paste the code below to achieve this (instead of the code that's already there and quite similar):
// find the record with the unique column value equal to the parameter value
String colVal;
%>Searching:<br><br><%
while (Details_hasData) {
colVal = ((MM_rs.getObject(MM_uniqueCol)!=null)?MM_rs.getObject(MM_uniqueCol).toString():""
%><%=colVal%> =? <%=param%><br><%
if (colVal.equals(param)) break;
%>no...<br><%
Details_hasData = MM_rs.next();
MM_offset++;
}
%>offset: <%=MM_offset%><%
[/li][/ul]
Don't know if this helps :~/
allow thyself to be the spark that lights the fire
haslo@haslo.ch - www.haslo.ch
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.