Click here to Skip to main content
15,880,503 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
please guide i want code just want to show table on browser with edit button.
if i click on edit it should be change.
this all be in JSP or struts with mysql.
which get more easy JSP or struts?
Posted

1 solution

1. create a Java bean class for grid view
example:
public class Student{
private String studentid,studentname,classname;
public Student(String studentid,studentname,classname){
this.studentid=studentid;
this.studentname=studentname;
this.classname=classname;
}

getter methods added
}

2. create action support class

create bean object(Student)

select data from database

store data to resultset
add thesse data to bean
example:

public class ActionSupportClass extends ActionSupport
{
private List<student> student=new ArrayList<>();

//getter methods of student

public String studentdetails()
{
//write connection string mysql
//write execute query
// assign result to ResultSet

while(res.next()){

student.add(new Student(res.getString(1),res.getString(2),res.getString(3)));
}
}
}

3. In jsp page


HTML
<table>
<tr><th>Student name</th><th>Class</th></tr>


<s:iterator value="requisitionreport" status="status" xmlns:s="#unknown">

<s:property value="studentname"><s:property value="classname">Details

XML
</table>

4. create jquery and add method viewdetails(action,studentid)
example
function viewdetails(action,studentid){
// add ajax post action and return result as json
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900