File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes html:select vanishing values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "html:select vanishing values" Watch "html:select vanishing values" New topic

html:select vanishing values

Ardoks Mathews

Joined: Feb 21, 2005
Posts: 2
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

Joined: Feb 15, 2005
Posts: 4864

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.


Consultant, Sima Solutions
I agree. Here's the link:
subject: html:select vanishing values
jQuery in Action, 3rd edition