I've got the pragprog stripes book, and have started creating a webapp
with stripes.  I'm confused about something though.

Say I've got a simple model object like:

public class User {
  long id;
  String email;
  String password;
  /* getters, setters, hashCode, equals, toString, etc */
}

And a UserForm actionbean:

public class UserForm extends BaseActionBean {
  public User user;
  /* standard getter/setter for the user field */

  @DefaultHandler
  public Resolution form() {
    return new ForwardResolution("path/to/user_form.jsp");
  }

  public void save() {
    User user = getUser();
    dao.save(user);
    return new RedirectResolution(UserList.class);
  }
}

And a user_form,jsp page:

<s:form beanclass="some.action.UserForm">
  <div><s:hidden name="user.id" /></div>
  <table class="form">
    <tr>
      <td>email</td>
      <td><s:text name="user.email" /></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>
        <s:submit name="save" value="save" />
      </td>
    </tr>
  </table>
</s:form>

And a standard, id-based TypeConverter and Formatter for the User class.

Whew, ok, that's the setup.  Notice that in user_form.jsp, I DON'T
have a <s:text name="user.password" /> field.  I don't want one, nor
do I want to put the password in a <s:hidden name="user.password" />
field.  Another use case, say there's an object with 25 fields, and I
specifically want to modify 3 of them; I don't want to write out 22
hidden fields.  When I load the user_form.jsp with ?user=29, the email
address textfield and the hidden field are filled in properly, thanks
to the typeconverter.  When I submit, the User user = getUser(); line
in the save() event return a user with a null password field (which
then NPE's the dao attempting to save the object, which is another
issue).  I want that password field to be whatever is currently in the
DB, and simply overwrite the fields that are posted from the form.

So how do I do this?  Or is this not the Right Way to be doing things
(I don't want to use Stripersist yet)?

Cheers,

Eric

------------------------------------------------------------------------------
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to