Github user jmewes commented on a diff in the pull request:

    https://github.com/apache/wicket/pull/341#discussion_r235872442
  
    --- Diff: 
wicket-user-guide/src/main/asciidoc/modelsforms/modelsforms_4.adoc ---
    @@ -75,28 +75,27 @@ public class LoginForm extends Form {
                if(username.equals("test") && password.equals("test"))
                        loginStatus.setDefaultModelObject("Congratulations!");
                else
    -                   loginStatus.setDefaultModelObject("Wrong username or 
password!");                       
    +                   loginStatus.setDefaultModelObject("Wrong username or 
password!");
        }
    -}
    -----
    +}Teh
     
     Inside form's constructor we build the three components used in the form 
and we assign them a model containing an empty string:
     
     [source,java]
     ----
     usernameField = new TextField("username", Model.of(""));
    -passwordField = new PasswordTextField("password", Model.of(""));           
        
    +passwordField = new PasswordTextField("password", Model.of(""));
     loginStatus = new Label("loginStatus", Model.of(""));
     ----
     
     If we don't provide a model to a form component, we will get the following 
exception on form submission:
     
     [source,java]
     ----
    -java.lang.IllegalStateException: Attempt to set model object on null model 
of component: 
    +java.lang.IllegalStateException: Attempt to set model object on null model 
of component:
     ----
     
    -Component TextField corresponds to the standard text field, without any 
particular behavior or restriction on the allowed values. We must bind this 
component to the <input> tag with the attribute type set to "text" 
PasswordTextField is a subtype of TextFiled and it must be used with an <input> 
tag with the attribute type set to "password". For security reasons component 
PasswordTextField cleans its value at each request, so it will be always empty 
after the form has been rendered. By default PasswordTextField fields are 
required, meaning that if we left them empty, the form won't be submitted (i.e. 
_onSubmit_ won't be called). Class FormComponent provides method 
_setRequired(boolean required)_ to change this behavior. Inside _onSubmit_, to 
get/set model objects we have used shortcut methods _setDefaultModelObject_ and 
_getDefaultModelObject_. Both methods are defined in class Component (see class 
diagram from Illustration 9.1).
    +Component TextField corresponds to the standard text field, without any 
particular behavior or restriction on the allowed values. We must bind this 
component to the <input> tag with the attribute type set to "text" 
PasswordTextField is a subtype of TextField and it must be used with an <input> 
tag with the attribute type set to "password". For security reasons component 
PasswordTextField cleans its value at each request, so it will be always empty 
after the form has been rendered. By default PasswordTextField fields are 
required, meaning that if we left them empty, the form won't be submitted (i.e. 
_onSubmit_ won't be called). Class FormComponent provides method 
_setRequired(boolean required)_ to change this behavior. Inside _onSubmit_, to 
get/set model objects we have used shortcut methods _setDefaultModelObject_ and 
_getDefaultModelObject_. Both methods are defined in class Component (see class 
diagram from illustration 9.1).
    --- End diff --
    
    > from Illustration 9.1).
    
    Illustration should be in lower-case.


---

Reply via email to