• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Capture list of checked rows from JSP

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

In JSP page I need to show records with the checkbox. The user ticks the one or more records that need to be delete and clicks the submit button as one action. At the server side, the servlet should extract all the ticked rows and perform delete task. This exercise is to avoid multiple delete action by the User. Now my question is how to store the checked rows in the page and send to server to process. Any help on this is appreciated.

Thanks in advance
Jo
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Josephine,

Let me assume that u have 3 fields as one record...and you are displaying each records with one checkbox.These records are shown using Jsp.While displaying every record , hope you will be using one "for loop" and adding the checkbox at the right end or left end of the row.Each record would have one primary key value ..say for example..employee number or something..so you can have the primary key value of each record as the check box values(ex:emp no) and checkbox name as some useful text.

so , while displaying 10 records, you will have 10 checkboxes which has 10 unique values...right?..now..u r ticking some check boxes...and submitting this form to a servlet...you can get the ticked check box values at the servlet using getParameterValues()..This function will return an array of all the unique values of checkboxes...right?...then u can execute the delete query in a "for loop" ,using these unique values in where condition to delete the records from the table..

Hope , you could have understood the flow .
 
Josephine Anthony
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rajaguru,

Thank you for your timely help. I understood the flow and I am implementing as per your flow.

May be in future, I use struts. Will the same flow applicable or do I need to extract the checked rows in different way?

Thank you again
Jo

Originally posted by Rajaguru Ramalingam:
Hi Josephine,

Let me assume that u have 3 fields as one record...and you are displaying each records with one checkbox.These records are shown using Jsp.While displaying every record , hope you will be using one "for loop" and adding the checkbox at the right end or left end of the row.Each record would have one primary key value ..say for example..employee number or something..so you can have the primary key value of each record as the check box values(ex:emp no) and checkbox name as some useful text.

so , while displaying 10 records, you will have 10 checkboxes which has 10 unique values...right?..now..u r ticking some check boxes...and submitting this form to a servlet...you can get the ticked check box values at the servlet using getParameterValues()..This function will return an array of all the unique values of checkboxes...right?...then u can execute the delete query in a "for loop" ,using these unique values in where condition to delete the records from the table..

Hope , you could have understood the flow .

 
pie. tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic