Win a copy of Rust Web Development this week in the Other Languages 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

CheckBok not storing Values

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI all,

I have few Checkboxes,

<html:checkbox name="chk_CMA"value="on">
and
in my bean i have
public boolean chk_CMA;

public boolean isChk_CMA() {
return chk_CMA;
}

public void setChk_CMA(boolean b) {
chk_CMA = b;
}
and in my database insert query i check if it is checked then insert the value, It is inserting the value. and when the page is returnback, all the check box values are lost (checked ones becomes vanished).
Kindly help in solving the issue. i would like to retain the checked ones
Thanks
Rudresh
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Definately you have defined action and action form for this in your applicaiton.

But when you load the page first time, the values are papulated from database but how the ActionForm will come to know what are the values.

So set the values while using the setter method in execute method of your action when you fetch data from database.

This will resolve the problem and data will be displayed to html page properly.

...execute(request,respone,form....){

if(valueindb){
{
form.setCheckBox(true)
}else{
form.setChckBox(false)
}

remember the form instance should be the same which is passed to execute method of action.
}
 
Heroic work plunger man. Please allow me to introduce you to this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic