• 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

load checkbox items at startup

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

I have made a page with a list of checkboxes. These are created with the '<html:multibox>'-tag.
These checkboxes should be checked when the page is loaded and the user has not given input yet. I can not do this via the corresponding ActionForm. The ActionForm uses a list to register all checked options from the list, but not all items from the list. Somehow I can not load this list with all items.

At this moment I solved the problem by using JavaScript. But JavaScript leads to many unpleasant surprises: for instance, when the page is reloaded, or redirected to the same page, all of the list items return unchecked.

Is it possible to do this using Struts or plain Java? I would like to know, because extending the page is becoming increasingly difficult.

Thank you in advance,

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

I can not do this via the corresponding ActionForm.


Try changing the default values in the ActionForm, i.e. set boolean values to true instead of false. When the ActionForm is instantiated, these values will be true and should have checkbox selected when displayed on screen.
[ October 22, 2008: Message edited by: James Clark ]
 
Albert Moorhill
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Multibox uses a list with items to register which checkbox items should be selected. When a multibox item corresponds with an item in that list, it receives a check.

To load items in the list with a check you can:
-initialize the list in the ActionForm with the items you want to be selected at startup
-use a setter method in the Action class to fill the list.

I found a simple example at http://www.ibm.com/developerworks/library/j-sr3.html

I do not know why I did not found the solution earlier. It seems to be a combination of overcomplicated code with an overcomplicated programmer

Albert
 
reply
    Bookmark Topic Watch Topic
  • New Topic