This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

checkbox checked always if only checked for the first time

 
scott prichard
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I am trying out some stuff in javascript and wanted to check whether the situation where if we check the checkbox once, it should remain checked always. In other terms it needs to be persisted. Is it possible and if so can you suggest a best practice because I heard its not best practice to make database calls from UI.

Thanks
Scott
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64973
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by scott prichard:
I heard its not best practice to make database calls from UI.


It's a horrible practice to perform DB access in the UI.

But without more info about your app, there's not much help you can get. For example, what's powering the backend? Servlets? php? Other?
 
scott prichard
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The request goes into a servlet and the database operatiosn are by session beans.

Scott
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64973
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you are using EJB?
 
scott prichard
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes i am using ejb.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64973
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then I'm not sure where you are having an issue. The state of the checkbox will be submitted back to the server, the server can persists it however it likes. When the page is requested the page controller for the JSP fetches the state and sends it to the page where the checkbox markup can be accordingly contstructed.

Where's the problem? Is it in constructing the HTML? Storing the state on the server? Fetching the state?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic