File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

html:select vanishing values

 
Ardoks Mathews
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
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" />
</html:select>
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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ardokos,

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.

Merrill
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic