1. Make sure that you are overriding the reset() method in the ActionForm.
2. In reset(), make sure you do NOT reset the value of the Collection that contains your multibox options, but make sure that you DO reset all other values besides your Collection.
3. set scope="session" as was suggested


The result is that your Collection gets set in your Action and left alone on validation failure. The other properties are handled per the quote you referenced below.

As for why it is that Struts doesn't repopulate the Collection for you from the request, essentially it has no way of knowing that they exist as they are not in the request when you submit the form. Only the values you select are. This is not true of text inputs because they return empty strings, but are still present in the request. I imagine something could be added to Struts that would add a bunch of hidden fields to the form in your .jsp that could somehow describe the type of the members of the Collection, and then rebuild the collection on the fly based on those fields. Perhaps this would make more sense after java 1.5 is released with support for typed Collections.

David

Mykola Ostapchuk wrote:

Doesn't work with session scope too.

"As we know, Struts redirects to the path set in the "input" attribute for
the action if there are errors present in ActionError object.
The ActionForm object holding the user's data will still be in request.
Thus, any data entered by the user in the form will appear pre-populated in
the form."

All the data in <html:text..> tags is pre-populated well. But multibox -
not...
Any suggestions?



----- Original Message ----- From: "Richard Raquepo" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>; "Mykola
Ostapchuk" <[EMAIL PROTECTED]>
Sent: Tuesday, June 17, 2003 11:15 PM
Subject: Re: Multibox persistence problem





try setting scope="session" in your action.
HTH
----- Original Message -----
From: "Mykola Ostapchuk" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, June 18, 2003 10:35 AM
Subject: Multibox persistence problem




Hi,

I'm using multibox to display multiple checkboxes:

<font size=2><pre>
<logic:iterate id="item" name="allRoles">
<html:multibox name="requestUser" property="selectedRoles">
  <bean:write name="item" property="value"/>
</html:multibox>
<bean:write name="item" property="label"/>
</logic:iterate>
</pre></font>

Everything works fine, the only problem is - when there's a validation


error


on my form and it's reposted with error messages, it always return all
checkboxes unchecked (even if I check some of them before).

How could I keep checkbox values in this situation?


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]








---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]









--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to