File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes not able to delete specific record after selecting it as radio button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "not able to delete specific record after selecting it as radio button" Watch "not able to delete specific record after selecting it as radio button" New topic
Author

not able to delete specific record after selecting it as radio button

dibakar sinha
Greenhorn

Joined: Oct 02, 2011
Posts: 15
Using Spring mvc(using multiactioncontroller)how to delete a specific record after displaying them in a table and selecting them as radio button,,,, i can make code understand(in controller) which radio button is clicked but not able to get the userid(primary key) for that radio button!!!please give me some sample code here!!!
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3838

, i can make code understand(in controller) which radio button is clicked but not able to get the userid(primary key) for that radio button!!!please give me some sample code here!!!

Without much of details it's hard someone to help here. You need to tell more details (TellTheDetails).

What's the value passed to the controller in this case, is this the ID or something else? And what you have used to access the database so far, any ORM tool or plain JDBC etc...?


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
dibakar sinha
Greenhorn

Joined: Oct 02, 2011
Posts: 15
my jsp from which i am reading which radio button is cliked is a below
<body><form action="jspcheck.do" method="post">
<%int i=0; %>
<table border="1" width="">
<tr>
<th></th><th>userId</th><th>userName</th><th>deptName</th>
</tr>
<c:forEach items="${user}" var="user">

<tr>
<td><input type=radio value="<%=i%>" name="group1"></td><td>${user.userId}</td><td>${user.userName}</td><td>${user.deptName}</td>
<%i++; %>
</tr>
</c:forEach><tr><td><input type="submit" name="delete" value="delete"></td></tr>
</table></form>
</body>
MY controller where I am sensing which radio button is clicked is as below
public ModelAndView jspcheck(HttpServletRequest request, HttpServletResponse response) throws Exception {
int i=0;
try {
for(i=0;i<10;i++) {
String value=request.getParameter("group1");
if(Integer.parseInt(value)==i) {
System.out.println(i+" radio button is selected");
int b=user.userId;
break;
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return new ModelAndView("redirect","message",i);
}


I am able to know which radio button is clicked but unable to get the user id related to that radio button....I am using Hibernate ORM
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: not able to delete specific record after selecting it as radio button