What is the difference between getModel() and getDefaultModel() in a Wicket Form?

Jemolah

Using Apache Wicket 7. Which model should be used in a Form? The default model of the component or the model of the form itself?

biziclop

The only difference is that getModel() is typesafe, but they both return the same object.

Here's the 7.0.0 implementation of Form.getModel() for example:

@Override
@SuppressWarnings("unchecked")
public final IModel<T> getModel()
{
    return (IModel<T>)getDefaultModel();
}

This all goes back to the Wicket 1.3 -> 1.4 transition, which introduced generics into Wicket, and the design decision was to rename the old getModel() method to getDefaultModel() and redefine getModel() in certain components to use the type parameter of that component.

Long story short: just use getModel() wherever possible.

This is unrelated to the choice of whether you use individual component models, or one big model for the form.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

What's the difference between getModel and getDevice?

What is the difference between Model, PropertyModel and CompoundPropertyModel in Wicket?

what is the difference between Django form and html form

Difference between AjaxLink and AjaxButton in Wicket

What is the difference between Form.Move and Form.LocationChanged?

what's the difference between a form_for and form_tag object?

Difference between Apache Tapestry and Apache Wicket

What is the difference between clearForm and resetForm in jQuery form plugin?

What is the difference between unique form algorithms and unique of the list container?

What is the difference between using ngModel and [(ngModel)] in form items?

What is the difference between "Form Controls" and "ActiveX Control" in Excel 2010?

What is the difference between window form topmost? C#

What's the difference between location vs desktoplocation in win form?

What is the difference between ajax post request and form post request?

What is difference between these two method of updating DB using form?

What's the difference between 'form#myForm' and '#myForm' in Jquery?

Postman Chrome: What is the difference between form-data, x-www-form-urlencoded and raw

What is the basic difference between form_submit hook and hook_form_submit in Drupal 7

What is the difference between multipart/form-data and application-x-www-form-urlencoded?

What is the difference between attaching a listener to a button to send form data with AJAX and using a standard HTML form?

What is the difference between using rails form_tag and html form code in an erb file?

What exactly is the difference between {$taxonomy}_add_form_fields and {$taxonomy}_add_form

What is the difference between *++a and ++*b?

What is the difference between && and ||?

What's the difference between "as?", "as!", and "as"?

What is the difference between :: and . in Rust?

What is the difference between //*[*] and //*[.] in XPath?

What is the difference between `cat |` and `<`

What is the difference between this and (this)?