Re: Form submit - button click

2015-09-04 Thread Mihir Chhaya
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 <
tobiassolosche...@googlemail.com> wrote:

> First ;-)
>
> kind regards
>
> Tobias
>
> > Am 04.09.2015 um 08:50 schrieb Bernard :
> >
> > 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 
> 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 form = new Form("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
> >> form) {
> >>PasswordTextField passwordTextField = new
> >> PasswordTextField(property);
> >>passwordTextField.setOutputMarkupId(true);
> >>passwordTextField.setRequired(true);
> >>passwordTextField.setMarkupId(property.concat("Id"));
> >>
> >>return passwordTextField;
> >>}
> >>
> >>private RequiredTextField userNameField(String property,
> >> Form form) {
> >>RequiredTextField userNameFld = new
> >> RequiredTextField(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
> >> 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:
> >>
> >> 
> >>
> >>
> >>
> >>
> >>User Name:
> >>
> >>
> >> >> placeholder="User Name" style="width:250px; text-align:left;">
> >>
> >>
> >>
> >>
> >>Password:
> >>
> >>
> >> >> placeholder="Password" style="width:250px; text-align:left;">
> >>
> >>
> >>
> >>
> >> >> wicket:id="login-button"/>
> >>
> >>
> >>
> >>
> >>
> >> Thanks,
> >> -Mihir.
> >>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: How can I modify onclick attribute of Link (wicket7) ?

2015-09-04 Thread xesj
Thank You. This is perfect solution:

add(
  new Link("linkWithConfirm") {
@Override
public void onClick() {
  setResponsePage(Abc.class);
}
@Override
protected void onComponentTag(ComponentTag tag) {
  // parent makes attributes
  super.onComponentTag(tag);
  // modify onclick attribute
  String parentOnclick = tag.getAttribute("onclick");
  String newOnclick = "if (!confirm('Sure ?')) return false; " +
parentOnclick;
  tag.put("onclick", newOnclick);
}
  }
  .setPopupSettings(new PopupSettings())
);


--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/How-can-I-modify-onclick-attribute-of-Link-wicket7-tp4671900p4671902.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: How can I modify onclick attribute of Link (wicket7) ?

2015-09-04 Thread Martin Grigorov
Hi,

See org.apache.wicket.markup.html.link.Link#onComponentTag().
You override the popup settings with your alert.

You may need to
override org.apache.wicket.markup.html.link.Link#onComponentTag() to be
able to preserve the popup settings.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Fri, Sep 4, 2015 at 10:42 AM, xesj  wrote:

> Hi !
>
> When a Link doesn't open popup window, I can write onclick in html code:
>...
>
> But 'popup' Link rewrites onclick attribute.
> I tried to modify this javascript, but this example isn't working:
>
>   add(
>   new Link("linkWithConfirm") {
> @Override
> public void onClick() {
>   setResponsePage(Abc.class);
> }
> @Override
> protected CharSequence getOnClickScript(CharSequence url) {
>   return "alert('run!!!'); " + super.getOnClickScript(url);
> }
>   }
>   .setPopupSettings(new PopupSettings())
> );
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/How-can-I-modify-onclick-attribute-of-Link-wicket7-tp4671900.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


How can I modify onclick attribute of Link (wicket7) ?

2015-09-04 Thread xesj
Hi !

When a Link doesn't open popup window, I can write onclick in html code:
   ... 

But 'popup' Link rewrites onclick attribute.
I tried to modify this javascript, but this example isn't working:

  add(
  new Link("linkWithConfirm") {
@Override
public void onClick() {
  setResponsePage(Abc.class);
}
@Override
protected CharSequence getOnClickScript(CharSequence url) {
  return "alert('run!!!'); " + super.getOnClickScript(url);
}
  }
  .setPopupSettings(new PopupSettings())
);

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/How-can-I-modify-onclick-attribute-of-Link-wicket7-tp4671900.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org