I agree with Johan. Wicket does not restrict you, and it is generally
easy to work with page instance variables etc. However, espectially
for larger apps, it works better if you work with proper models (like
a model that holds a user which you set on the page, and then the
property model that works on that model instead of the page instance)
because it will be easier to refactor.

Eelco

On 12/22/05, Johan Compagner <[EMAIL PROTECTED]> wrote:
> There could be a third approach and that is holding the model as a
> reference.
> Then versioning would go fine if you use it for formcomponents (switched of
> by default) so that is not a problem in the second approach you do
> what i think most people are doing.
>
> johan
>
>
>
>
> On 12/22/05, karthik Guru <[EMAIL PROTECTED] > wrote:
> >
> > What is typically held as instance variable in the Page class? - the
> property that am actually interested in / component that updates the
> property.
> >
> > Say I have a page with a Form and a TextField as follows.
> >
> > public class Login extends WebPage {
> >
> >  private TextField userIdField;
> >
> >  public Login() {
> >   Form form = new Form("loginForm") {
> >
> >    public void onSubmit() {
> >     String userId = Login.this.getUserId();
> >     System.out.println("User id was " + userId);
> >    }
> >   };
> >   userIdField = new TextField("userId",new Model(""));
> >   form.add(userIdField);
> >  }
> >
> >
> >  public String getUserId() {
> >   return userIdField.getModelObjectAsString();
> >  }
> >
> > }
> >
> > OR
> > public class Login extends WebPage {
> >
> >
> >  private String userId;
> >
> >  public Login() {
> >   Form form = new Form("loginForm") {
> >
> >    public void onSubmit() {
> >     String userId = Login.this.getUserId();
> >     System.out.println("User id was " + userId);
> >    }
> >   };
> >   TextField userIdField = new TextField("userId", new
> PropertyModel(this,"userId"));
> >   form.add(userIdField);
> >  }
> >
> >  public String getUserId() {
> >   return userId;
> >  }
> >
> >  public void setUserId(String userId) {
> >    this.userId = userId;
> >  }
> > }
> >
> > I like the latter. I dont like holding on to the widget instances as
> properties in my page, i would rather have the property as Page instance
> variables as am more interested in their values. Can somebody comment on
> this. What is the recommended way?
> >
> > thanks, karthik
>
>


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to