Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Is this A bean or db design problem

 
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a set of chkboxes on a jsp page. These checkboxes values are givien from a db. So I call a loop to show checkboxes. Problem being, is tat on my other jsp page that I allow to modify it, I would like to use the most effcient way to show all the checkboxes and which ones were checked an unchecked from the last time.
I will attempt to show some pusedocode just in case I lost anyone.
add.jsp
*******
1. Loop that prints checkboxes and their values.
2. For gets send to servlet and inserts the ID of those that were checked
modify.jsp
********
Needs to show all chckboxes with onyl the ones with reocrds in the db checked...
Will this invlove 2 for loops or is their a better way?
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
pal ii am making a few assumptions
1)The number of checkboxes on u'r screen are not dynamic ,i.e. there are a fixed number of check boxes on u'r screen.
2)You are checking the checkboxes in Add mode and their state is getting saved in the Database .
3) In update mode u want to display the chechBoxes with state populated from the database .
U could go about it in this fashion .Execute a query when u call enter the jsp in Update mode which query's the database for the state of the checkBoxes.
Form a delimited String on the server with values from the resultset . Typically it's gonna look like
Y%Y%N%N%Y where Y stands for a checked checkBox & N for a unchecked CheckBox & % is a delimiter . Assign this java Array to a javaScript array .
using split() function .
Now u can assign the values to individual checkBoxes using javaScript in a function called on body onLoad().....
Please mail if u need any further clarifications.
Sachin
 
Anthony Smith
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got your answers to the post but the # of checkboxes will be dynamic cause the values of the checkboxes are coming from the db, and some can get added to make more checkboxes. When I go to update, I still want all of my checkboxes to appear in the same place, ut I want some to seem checked and the other to be blank
 
reply
    Bookmark Topic Watch Topic
  • New Topic