you can use a model:

class preferencemodel implements imodel {
private final IModel delegate;
private final String key;

 public preferencemodel(string key, imodel delegate) {
   this.key=key;this.delegate=delegate;
  }

  object getobject() {
     object o=delegate.getobject();
     if (o==null) {
        // initialize from db
        o=loadpreffromdb(key);
        delegate.setobject(o);
      }
      return o;
    }

    void setobject(object o) {
      savepreftodb(key, o);
      delegate.setobject(o);
     }

     void detach() { delegate.detach(); }
}

and then add(new TextField("name", new preferencemodel("username", new
PropertyModel(this, "name")));

or if you want to keep the transparency you can override
requestcycle.onbeginrequest() and persist there if  the request was a post.
restoring values will be trickier, i would probably create a subclass of
form that visits all formcomponents in onbeforerender() and sets their
values from the db.

-igor


On 5/21/07, Ravindra Wankar <[EMAIL PROTECTED]> wrote:

Hello,

In our current application, we remember a lot of form parameters,
sorting preferences across user sessions by saving them in the database.
The implementation is simple and *transparent*; we name these fields
(text boxes, select lists, etc.) starting with "saved." and for every
request, save the associated key-value pairs from HttpServletRequest in
the database. While rendering these fields, we lookup the database for
the saved values which are treated as defaults.

Question is how to do this in wicket?

Thank you.
Ravi





-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to