• 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
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Struts2: Checkboxlist defaulting selected values.

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

I am a self taught Java developer, and am very new to Struts. I've been working on a project for a while now and have tried to refrain from asking "newbie" questions, however, there is something that has eluded me for some time, which seems to be very simply. I am trying to default selected items in a checkboxlist. I have searched this site and read the numerous similar topics where solutions have been offered. Either I am going mad, I'm making a newbie error or am missing something vital.

So I hope someone will be able to help.

To summarise. I have a checkboxlist that is displaying a list of available Locales/Languages (which is retrieved from a SQL Table). I am trying to have some of these ticked by default. This is what I have:

userManager.jsp


This currently displays 4 checkbox's, none of which are ticked. And the HTML looks like this:

userManager - generated HTML


While they are not visible above, the "values" of the checkbox items above do indeed cotnain an underscore, so en_FI, en_DK, en_NO for example.

The function getLanguagesSelected is as follows (currently hard coded, just to get this to work):

UserActions.java


Just to clarify, I have put a breakpoint in the above function and I know it is being called. So why doesn't it select the two checkboxes in my String Array?

Thanks in advance for any help you can offer.
 
Alex Fiorello
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, it was an embarrassing mistake!

The way I define my String Array on line 02 of UserActions.java is wrong! This would produce just one array item of "en_FI, en_NO" rather than 2 items.

If should have been:



Which actually makes everything work as expected.
 
reply
    Bookmark Topic Watch Topic
  • New Topic