wood burning stoves 2.0*
The moose likes JSP and the fly likes Bug in code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Bug in code" Watch "Bug in code" New topic
Author

Bug in code

prathimaprasun rao
Ranch Hand

Joined: Jun 29, 2006
Posts: 55
hello everyone,
I have a jsp that has the following fields on the form:
1. studentid
2.studentname
3.performance
4.class
5.teacher
5.principal.
All the above fields information is stored in "student" table.

Teacher assigns the value to performance field for each student.This field can have any one of the three values:
1. Poor
2.Improving
3.Good

This form allows the user to add/edit student information in add/edit mode.
During add mode, the student record is created. If there is change in that students information, the teacher edits that record data during edit mode.
The principal can edit student information.
Now my goal is to disable the studentid field when the student performance changes from either poor/improving to good for the first time.When that performance field has good as value in it, then that studentid field needs to be disabled and the teacher will not be able to change the value in that field even if the value in that field changes from good to poor/improving. Only the principal should have the ability to change the value in that performance field during edit mode.

For that I have created a flag_code field in student table.My idea is when the flag_code field has N value for the first time, we should lock that field from changing to Y when we change the value in the performance field.

int status1=0, status2 =0;
int flagcount=0;
String flag="";
String iStr1 = "",iStr2="";

-----------------

//Modified Code:-
strSQL=" select performance from "student" where upper(studentid)='"+studentid.toUpperCase()+"'";

//out.println(strSQL);
//out.println("hi");
//out.println("<br>");
Statement stmt12 = conn.createStatement();
ResultSet rs12 = stmt12.executeQuery(strSQL);
while (rs12.next()) {
status1 = rs12.getInt(1);


}
out.println("status code:"+status1);
out.println("<br>");
rs12.close();
stmt12.close();
//retrieving status value

iStr1 = String.valueOf (status1);

if(iStr1.equals("3"))
{
strSQL1 = "update student set flag_code ='N' where upper(studentid)='"+studentid.toUpperCase()+"'";
flagcount+=1;
flag=String.valueOf(flagcount);
}
else
{
strSQL1 = "update student set flag_code ='Y' where upper(studentid)='"+studentid.toUpperCase()+"'";
//flagcount+=0;
}

db.setSQL(strSQL1);
db.update();
out.println("flag_code for studentid = "+" " +" "+studentid + "is " + " " +strSQL1);
out.println("<br>");
//flagcount+=1;
//flag=String.valueOf(flagcount);
out.println("flag :"+flag);
out.println("<br>");

-----------------------------------------

<form>
<%


if (mode.equals("add")||(mode.equals("edit") ||(flag.equals("1")&& (userProfile.equalsIgnoreCase("principal") ) ) )){


%>
<input type="text" name="studentid" value="<%=studentid%>" SIZE="13" MAXLENGTH="13">
<%
} else {
%>
<input type="text" name="studentid" disabled value="<%=studentid%>" SIZE="13" MAXLENGTH="13">
<%
}

The problem with my code is that I am unable to capture when the value changed to 3(good) either from 1 to 3 or 2 to 3.My code disabled the studentid field when the performance field has value 1 or 2 during edit mode before it changes to 3 for the first time.
The goal is:
The studentid field should be active during add mode.
The field should also be active in edit mode as long as the performance field value changes from 1 to 2 and vice versa.Once the performance field changes from 1 or 2 to 3 for the first time, the studentid field should be blocked even though the value changes from 3 to either 1 or 2 during edit mode. Could anyone let me know how to solve this issue?

Thanks,
prathima.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extermely hard to read and most people will just go elsewhere. Please read this for more information.

You can go back and change your post to add code tags by clicking the .


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Bug in code
 
Similar Threads
To use or not to use SingleThreadModel?
Disable and enable one particular field
ID attribute DTD
in which method shuld i use at the servlet code for request
Problem regarding redirected error message