You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Tom Bowditch <tb...@transite.com> on 2003/05/10 01:51:06 UTC

Question with clearing a String[] Multibox from a session scoped DynaActionForm

Hello,

I have the following problem.  On a multi .jsp page form one of the fields
is a String[] that is handled with a multibox similar to the following

      <table width="100%" border="1">
      <% for (int i=0; i<stateArray.length; i++) { %>
        <tr>
        <% for (int j=0; j<stateArray[i].length; j++) { %>
          <td align="right">
            <% if (stateArray[i][j] != null) { %>
               <%= stateArray[i][j] %>
              <html:multibox property="originStates" value="<%=
stateArray[i][j] %>"/>
            <% } // end of if %>
          </td>
        <% } // end of for j %>
        </tr>
      <% } // end of for i %>
      </table>

The code allows the user to select states according to checkboxes which get
returned in the String[] property.
There is no validation done untill the final submission.  The field is not a
required field.

Everything works fine, until there is an error.  When the user is sent back
to this page, the multiboxes are all correctly set to what the user selects.
But when the user unselects everything the change doesn't show up in the
DynaActionForm.

What I believe is going on is:

User sets a field in the DynaActionBean. User tries to unset the field (on a
later request) in DynaActionBean by leaving it empty.  This causes the http
form to not include that parameter in the submission.  The DynaActionForm
then doesn't recognize that it needs to update the field to 'null' or empty.

I think this could potentially happen to any field in a session scoped form.

Anyone have an idea on how to get around this?

I suppose I could go from session scope to request scope and have lots of
hidden fields so a new DynaActionBean is always generated but I'd rather not
have to do this.

Thanks for any help.

Tom





---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org