| Author |
Retrieve the Updated "name Value" in the textbox for each row and update in database on SUBMIT Oper
|
Prasanna.D Prasanna
Greenhorn
Joined: Nov 05, 2012
Posts: 2
|
|
Hi,
Requirement : To Retrieve the Updated "name Value" in the textbox for each row and update in database on SUBMIT Operation in JSP Form Using Struts Framework
I need retrieve the Textbox Values for all the rows in the table with unique identification on the SUBMIT Operation.
I have populated the tables using FormBean and which turns contain list EMPList .
<tabl border=1>
<logic:iterate name="insertForm" property="empList" id="sample" type="com.mystruts.Bean">
<tr><td><bean:write name="sample" property="name"></bean:write>
</td><td><bean:write name="sample" property="ID"></bean:write>
</td><td> <bean:write name="sample" property="doj"></bean:write>
</td><td> <html:text name="sample" property="name"/></td></tr>
</logic:iterate>
</tabl>
<html:submit>Repair</html:submit>
Kindly provide some idea to get the new values in the textbox for all rows in the table and provide to the Action Class Using Struts Framework.
Thanks,
Regards,
Prasanna D
|
 |
manovemula vemula
Greenhorn
Joined: Aug 20, 2012
Posts: 5
|
|
Hi
see the below code may be it's help full for you
import java.sql.*;
import java.util.*;
import javax.servlet.http.*;
import org.apache.struts.action.*;
public class RetrievDataActionServlet extends Action{
public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)throws Exception{
try{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection con = DriverManager.getConnection("jdbc racle:thin:@localhost:1521:XE","username","password");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("query");
ArrayList list = new ArrayList();
System.out.println("before the list:"+list.size());
while(rs.next()){
Emp e = new Emp();
e.setEno(rs.getInt(1));
e.setName(rs.getString(2));
e.setSalary(rs.getString(3));
list.add(e);
}
System.out.println("after the list:"+list.size());
request.setAttribute("list",list);
}
catch(Exception ie){
ie.printStackTrace();
}
ActionForward af = mapping.findForward("display");
return af;
}
}
|
 |
Prasanna.D Prasanna
Greenhorn
Joined: Nov 05, 2012
Posts: 2
|
|
Hi manovemula ,
Thanks for your usefull code snippet.
i am able to populate the Table by getting the data from the Database.
But am stuck at "How to retrieve the User entered Value in the TextBoxes present in iterative Rows in the table" and send back that data to ActionClass which inturns updates the database.
Can you suggest some inputs on that ?
Thanks,
Regards,
Prasanna D
|
 |
 |
|
|
subject: Retrieve the Updated "name Value" in the textbox for each row and update in database on SUBMIT Oper
|
|
|