You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Mihir Chhaya <mi...@gmail.com> on 2015/09/04 07:45:24 UTC
Form submit - button click
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.
Re: Form submit - button click
Posted by Tobias Soloschenko <to...@googlemail.com>.
Hi,
because the feedback panel is not a children of the form and you only add the form to the AjaxRequestTarget it is not updated.
Try to add the feedback panel to the ART in the submit, too.
kind regards
Tobias
> Am 04.09.2015 um 07:45 schrieb Mihir Chhaya <mi...@gmail.com>:
>
> 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.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Form submit - button click
Posted by Mihir Chhaya <mi...@gmail.com>.
Such an obvious thing :) yes, it is working now with having panel added to
form and to ART. Thanks for your help.
-Mihir.
On Fri, Sep 4, 2015, 2:53 AM Tobias Soloschenko <
tobiassoloschenko@googlemail.com> wrote:
> First ;-)
>
> kind regards
>
> Tobias
>
> > Am 04.09.2015 um 08:50 schrieb Bernard <bh...@gmail.com>:
> >
> > 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 <mi...@gmail.com>
> 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.
> >>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: Form submit - button click
Posted by Tobias Soloschenko <to...@googlemail.com>.
First ;-)
kind regards
Tobias
> Am 04.09.2015 um 08:50 schrieb Bernard <bh...@gmail.com>:
>
> 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 <mi...@gmail.com> 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.
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Form submit - button click
Posted by Bernard <bh...@gmail.com>.
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 <mi...@gmail.com> 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.
>