Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!

  • Post Reply Bookmark Topic Watch Topic
  • New Topic

html:select vanishing values  RSS feed

Ardoks Mathews
Posts: 2
  • Mark post as helpful
  • send pies
  • 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
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • 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.

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!