• 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 ...
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • Al Hobbs
  • salvin francis

html:select vanishing values

Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using a html:select with multiple = true , i am populating it with a string array and accessing selecting values with another values like code gere

<html:select property="arrsel" multiple ="true">
<html ptions property="arrpop" />
where arrsel is the string array which gets filled up on selecting values and arrpop is string array for fetching values from form object, it is working fine but problem i am having is after selecting values if due to some validation error or or i have to go back the the select box becomes empty there are no values left which were coming earlier, although all other values in other fields like html:text are coming back fine, can somebidy help me with this please
I am using a reset method in form object as

public void reset(ActionMapping mapping, HttpServletRequest request)
arrpop = new String[0];
which if i don't use it get a null pointer exception that arrpop is null, i found on net i should use it.
I initialise my arrays like this in form
private String[] arrpop;
private String[] arrsel ;
and have got getter and setter for them
I am using session scope, so scope should not be a problem.
Thanks so much
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Try replacing the codde in your reset method with the following:

The reset() method does get called if validation fails, so this is why your values are getting wiped out. If you repplace arrpop with an empty array only if it is null, I think this should solve the problem.

You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic