This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
dibakar sinha
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 3930
21
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
, 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...?
 
dibakar sinha
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic