Your feedback component is not contained in any AJAX target. You add the
feedback component to the page which does not get refreshed after the form
submit.

AJAX is preferably used to avoid what you are expecting (page refresh).


On Fri, Sep 4, 2015 at 5:45 PM, Mihir Chhaya <[email protected]> wrote:

> Hello,
>
> I am finding problem while submitting form on button click.
>
> I have simple login form with login button. User name and password fields
> are required. The button type is submit in html. But when I click the
> button the page does not show feedback messages. On clicking browser page
> refresh/reload (F5) only I see the feedback message. Could anybody suggest
> me what I am missing?
>
> Here is the page:
>
> public class Login extends WebPage {
>
>     NotificationPanel feedbackPanel;
>
>     public Login() {
>
>         feedbackPanel = new NotificationPanel("statusbar");
>         feedbackPanel.setOutputMarkupId(true);
>         feedbackPanel.setMarkupId("statusbarId");
>         add(feedbackPanel);
>
>         Form<Void> form = new Form<Void>("login-form"){
>             @Override
>             protected void onSubmit() {
>                 super.onSubmit();
>                 System.out.println("Form onSubmit called...");
>             }
>         };
>         form.setOutputMarkupId(true);
>         add(form);
>         form.add(userNameField("username", form));
>         form.add(passwordField("password", form));
>         AjaxFallbackButton submitButton = addLoginButton("login-button",
> form);
>         form.add(submitButton);
>         form.setDefaultButton(submitButton);
>         form.setOutputMarkupId(true);
>     }
>
>     private PasswordTextField passwordField(String property, Form<Void>
> form) {
>         PasswordTextField passwordTextField = new
> PasswordTextField(property);
>         passwordTextField.setOutputMarkupId(true);
>         passwordTextField.setRequired(true);
>         passwordTextField.setMarkupId(property.concat("Id"));
>
>         return passwordTextField;
>     }
>
>     private RequiredTextField<String> userNameField(String property,
> Form<Void> form) {
>         RequiredTextField<String> userNameFld = new
> RequiredTextField<String>(property) {
>             @Override
>             protected void onComponentTag(ComponentTag tag) {
>                 super.onComponentTag(tag);
>                 if (!isValid()) {
>                     tag.put("style", "background-color:red");
>                 }
>             }
>         };
>         userNameFld.setOutputMarkupId(true);
>         userNameFld.setMarkupId(property.concat("Id"));
>
>         return userNameFld;
>     }
>
>     private AjaxFallbackButton addLoginButton(String property, Form<Void>
> form) {
>         AjaxFallbackButton submitBtn = new AjaxFallbackButton(property,
> form) {
>             @Override
>             protected void onSubmit(AjaxRequestTarget target, Form<?> form)
> {
>                 super.onSubmit(target, form);
>                 target.add(form);
>             }
>         };
>
>         submitBtn.setDefaultFormProcessing(true);
>
>         return submitBtn;
>     }
> }
>
>
> Here is Mark up:
>
> <div wicket:id="statusbar">
>         <form wicket:id="login-form">
>             <div style="width:100%">
>                 <div style="display:table-row;">
>                     <div class="login-l">
>                         User Name:
>                     </div>
>                     <div class="login-t">
>                         <input type="text" wicket:id="username"
> placeholder="User Name" style="width:250px; text-align:left;">
>                     </div>
>                 </div>
>                 <div style="display:table-row;">
>                     <div class="login-l">
>                         Password:
>                     </div>
>                     <div class="login-t">
>                         <input type="password" wicket:id="password"
> placeholder="Password" style="width:250px; text-align:left;">
>                     </div>
>                 </div>
>                 <div style="display:table-row;">
>                     <div class="button-container">
>                         <input type="submit" value="Login"
> wicket:id="login-button"/>
>                     </div>
>                 </div>
>             </div>
>         </form>
>
> Thanks,
> -Mihir.
>

Reply via email to