Re: Adding HTML class=invalid after validating with IndicatingAjaxButton
Thanks, Igor. I've been playing around with your suggestions but still doesn't seem to make it work. My onSubmit is not being called when I set a breakpoint there. Is it possible that what I am asking for is not possible? - Original Message From: Igor Vaynberg [EMAIL PROTECTED] To: users@wicket.apache.org Sent: Tuesday, September 23, 2008 10:48:54 PM Subject: Re: Adding HTML class=invalid after validating with IndicatingAjaxButton target.addComponent(feedback); target.addComponent(form); // you might have to add some div that is around the form, not sure if browsers support replacing form tag well -igor On Tue, Sep 23, 2008 at 1:39 PM, Chris Stein [EMAIL PROTECTED] wrote: Thanks, Igor. However, I tried it and it never showed up in the browser. Even more so, when I set a breakpoint to the onComponentTag-method, it never gets called. Is that correct? I only get this behavior when I am using the IndicatingAjaxButton--everything works fine with the regular buttons. Maybe I am missing something else here... Here's my code: /** * The panel with the form. */ public class SignInPanel extends Panel { public SignInPanel(final String id) { super(id); feedback.setOutputMarkupId(true); add(feedback); add(new SignInForm(signInForm)); } public final class SignInForm extends StatelessForm { private final ValueMap properties = new ValueMap(); public SignInForm(final String id) { super(id); FormComponent fc; fc = new RequiredTextField(username, new PropertyModel(properties, username)); fc.add(new InvalidIndicator()); fc.setOutputMarkupId(true); add(fc); fc = new PasswordTextField(password, new PropertyModel(properties, password)); fc.add(new InvalidIndicator()); fc.setOutputMarkupId(true); add(fc); AjaxFormValidatingBehavior.addToAllFormComponents(this, onsubmit); this.add(new IndicatingAjaxButton(submit, this) { @Override protected void onSubmit(AjaxRequestTarget target, Form form) { //perform sign in } @Override protected void onError(AjaxRequestTarget target, Form form) { target.addComponent(feedback); } }); } } /** * The validator. Thanks to Igor. */ public class InvalidIndicator extends AbstractBehavior { @Override public void onComponentTag(final Component component, final ComponentTag tag) { boolean valid = ((FormComponent)component).isValid(); if(!valid) { tag.getAttributes().put(class,invalid); } } } - Original Message From: Igor Vaynberg [EMAIL PROTECTED] To: users@wicket.apache.org Sent: Tuesday, September 23, 2008 5:50:08 PM Subject: Re: Adding HTML class=invalid after validating with IndicatingAjaxButton public class invalidindicator extends abstractbehavior { protected void oncomponenttag(component c, tag t) { boolean valid=((formcomponent)c).isvalid(); if (!valid) { tag.put(class,invalid); } } } formcomponent.add(new invalidindicator()); -igor On Tue, Sep 23, 2008 at 2:53 AM, cstein1206 [EMAIL PROTECTED] wrote: I basically want to achieve this: http://www.jroller.com/karthikg/entry/wicket_and_ajax but handle the validation only after the form has been submitted with an AjaxIndicatingButton instead of with the onblur as in the example. I think I tried too many things over the last couple of days and got totally confused now. Would anybody be so kind to help me out a bit? What do I need to add to the FormComponents so that they will be updated with an HTML-attribute class='invalid'? So far my form doesn't do that (I did setOutputMarkupId(true)). Thanks a ton! Chris -- View this message in context: http://www.nabble.com/Adding-HTML-class%3D%22invalid%22-after-validating-with-IndicatingAjaxButton-tp19624501p19624501.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Adding HTML class=invalid after validating with IndicatingAjaxButton
Override onError too Martijn On Thu, Sep 25, 2008 at 1:56 PM, Chris Stein [EMAIL PROTECTED] wrote: Thanks, Igor. I've been playing around with your suggestions but still doesn't seem to make it work. My onSubmit is not being called when I set a breakpoint there. Is it possible that what I am asking for is not possible? - Original Message From: Igor Vaynberg [EMAIL PROTECTED] To: users@wicket.apache.org Sent: Tuesday, September 23, 2008 10:48:54 PM Subject: Re: Adding HTML class=invalid after validating with IndicatingAjaxButton target.addComponent(feedback); target.addComponent(form); // you might have to add some div that is around the form, not sure if browsers support replacing form tag well -igor On Tue, Sep 23, 2008 at 1:39 PM, Chris Stein [EMAIL PROTECTED] wrote: Thanks, Igor. However, I tried it and it never showed up in the browser. Even more so, when I set a breakpoint to the onComponentTag-method, it never gets called. Is that correct? I only get this behavior when I am using the IndicatingAjaxButton--everything works fine with the regular buttons. Maybe I am missing something else here... Here's my code: /** * The panel with the form. */ public class SignInPanel extends Panel { public SignInPanel(final String id) { super(id); feedback.setOutputMarkupId(true); add(feedback); add(new SignInForm(signInForm)); } public final class SignInForm extends StatelessForm { private final ValueMap properties = new ValueMap(); public SignInForm(final String id) { super(id); FormComponent fc; fc = new RequiredTextField(username, new PropertyModel(properties, username)); fc.add(new InvalidIndicator()); fc.setOutputMarkupId(true); add(fc); fc = new PasswordTextField(password, new PropertyModel(properties, password)); fc.add(new InvalidIndicator()); fc.setOutputMarkupId(true); add(fc); AjaxFormValidatingBehavior.addToAllFormComponents(this, onsubmit); this.add(new IndicatingAjaxButton(submit, this) { @Override protected void onSubmit(AjaxRequestTarget target, Form form) { //perform sign in } @Override protected void onError(AjaxRequestTarget target, Form form) { target.addComponent(feedback); } }); } } /** * The validator. Thanks to Igor. */ public class InvalidIndicator extends AbstractBehavior { @Override public void onComponentTag(final Component component, final ComponentTag tag) { boolean valid = ((FormComponent)component).isValid(); if(!valid) { tag.getAttributes().put(class,invalid); } } } - Original Message From: Igor Vaynberg [EMAIL PROTECTED] To: users@wicket.apache.org Sent: Tuesday, September 23, 2008 5:50:08 PM Subject: Re: Adding HTML class=invalid after validating with IndicatingAjaxButton public class invalidindicator extends abstractbehavior { protected void oncomponenttag(component c, tag t) { boolean valid=((formcomponent)c).isvalid(); if (!valid) { tag.put(class,invalid); } } } formcomponent.add(new invalidindicator()); -igor On Tue, Sep 23, 2008 at 2:53 AM, cstein1206 [EMAIL PROTECTED] wrote: I basically want to achieve this: http://www.jroller.com/karthikg/entry/wicket_and_ajax but handle the validation only after the form has been submitted with an AjaxIndicatingButton instead of with the onblur as in the example. I think I tried too many things over the last couple of days and got totally confused now. Would anybody be so kind to help me out a bit? What do I need to add to the FormComponents so that they will be updated with an HTML-attribute class='invalid'? So far my form doesn't do that (I did setOutputMarkupId(true)). Thanks a ton! Chris -- View this message in context: http://www.nabble.com/Adding-HTML-class%3D%22invalid%22-after-validating-with-IndicatingAjaxButton-tp19624501p19624501.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Become
Re: Adding HTML class=invalid after validating with IndicatingAjaxButton
I went crazy and did this, I relied on I think Al Maw's thing from WUG London : Add the below visitor to your form, you can also easy do scriptacoulus effects with this approach eg make the offender shake.. package zeuzgroup.application.component; import java.io.Serializable; import java.util.HashSet; import java.util.Set; import org.apache.wicket.Component; import org.apache.wicket.Component.IVisitor; import org.apache.wicket.markup.html.form.FormComponent; public class ShinyFormVisitor implements IVisitor, Serializable { Set visited = new HashSet(); public Object component(Component c) { if (!visited.contains(c)) { visited.add(c); if (FormComponent.class.isInstance(c)) { c.setComponentBorder(new RequiredBorder()); c.add(new ValidationMsgBehavior()); c.add(new ErrorHighlightBehavior()); } } return IVisitor.CONTINUE_TRAVERSAL; } } package zeuzgroup.application.component; import org.apache.wicket.Component; import org.apache.wicket.behavior.AbstractBehavior; import org.apache.wicket.markup.ComponentTag; import org.apache.wicket.markup.html.form.FormComponent; public class ErrorHighlightBehavior extends AbstractBehavior { public void onComponentTag(Component c, ComponentTag tag) { FormComponent fc = (FormComponent) c; if (!fc.isValid()) { tag.put(class, error); } } } package zeuzgroup.application.component; import org.apache.wicket.Component; import org.apache.wicket.markup.html.border.MarkupComponentBorder; import org.apache.wicket.markup.html.form.FormComponent; public class RequiredBorder extends MarkupComponentBorder { public void renderAfter(Component component) { FormComponent fc = (FormComponent)component; if (fc.isRequired()) { super.renderAfter(component); } } } Required border html body wicket:border wicket:body/ span class=requiredHint*/span /wicket:border /body /html Chris Stein wrote: Thanks, Igor. I've been playing around with your suggestions but still doesn't seem to make it work. My onSubmit is not being called when I set a breakpoint there. Is it possible that what I am asking for is not possible? - Original Message From: Igor Vaynberg [EMAIL PROTECTED] To: users@wicket.apache.org Sent: Tuesday, September 23, 2008 10:48:54 PM Subject: Re: Adding HTML class=invalid after validating with IndicatingAjaxButton target.addComponent(feedback); target.addComponent(form); // you might have to add some div that is around the form, not sure if browsers support replacing form tag well -igor On Tue, Sep 23, 2008 at 1:39 PM, Chris Stein [EMAIL PROTECTED] wrote: Thanks, Igor. However, I tried it and it never showed up in the browser. Even more so, when I set a breakpoint to the onComponentTag-method, it never gets called. Is that correct? I only get this behavior when I am using the IndicatingAjaxButton--everything works fine with the regular buttons. Maybe I am missing something else here... Here's my code: /** * The panel with the form. */ public class SignInPanel extends Panel { public SignInPanel(final String id) { super(id); feedback.setOutputMarkupId(true); add(feedback); add(new SignInForm(signInForm)); } public final class SignInForm extends StatelessForm { private final ValueMap properties = new ValueMap(); public SignInForm(final String id) { super(id); FormComponent fc; fc = new RequiredTextField(username, new PropertyModel(properties, username)); fc.add(new InvalidIndicator()); fc.setOutputMarkupId(true); add(fc); fc = new PasswordTextField(password, new PropertyModel(properties, password)); fc.add(new InvalidIndicator()); fc.setOutputMarkupId(true); add(fc); AjaxFormValidatingBehavior.addToAllFormComponents(this, onsubmit); this.add(new IndicatingAjaxButton(submit, this) { @Override protected void onSubmit(AjaxRequestTarget target, Form form) { //perform sign in } @Override protected void onError(AjaxRequestTarget target, Form form) { target.addComponent(feedback); } }); } } /** * The validator. Thanks to Igor. */ public class InvalidIndicator extends AbstractBehavior { @Override public void onComponentTag(final Component component, final ComponentTag tag) { boolean valid = ((FormComponent)component).isValid(); if(!valid) { tag.getAttributes().put(class,invalid); } } } - Original Message From: Igor Vaynberg [EMAIL PROTECTED] To: users@wicket.apache.org Sent: Tuesday, September 23, 2008 5:50:08 PM Subject: Re: Adding HTML class=invalid after validating with IndicatingAjaxButton public class invalidindicator extends abstractbehavior { protected void oncomponenttag(component c, tag t) { boolean valid=((formcomponent)c).isvalid(); if (!valid) { tag.put(class,invalid
Re: Adding HTML class=invalid after validating with IndicatingAjaxButton
Thanks Martijn!!! That worked like a charm! - Original Message From: Martijn Dashorst [EMAIL PROTECTED] To: users@wicket.apache.org Sent: Thursday, September 25, 2008 1:59:41 PM Subject: Re: Adding HTML class=invalid after validating with IndicatingAjaxButton Override onError too Martijn On Thu, Sep 25, 2008 at 1:56 PM, Chris Stein [EMAIL PROTECTED] wrote: Thanks, Igor. I've been playing around with your suggestions but still doesn't seem to make it work. My onSubmit is not being called when I set a breakpoint there. Is it possible that what I am asking for is not possible? - Original Message From: Igor Vaynberg [EMAIL PROTECTED] To: users@wicket.apache.org Sent: Tuesday, September 23, 2008 10:48:54 PM Subject: Re: Adding HTML class=invalid after validating with IndicatingAjaxButton target.addComponent(feedback); target.addComponent(form); // you might have to add some div that is around the form, not sure if browsers support replacing form tag well -igor On Tue, Sep 23, 2008 at 1:39 PM, Chris Stein [EMAIL PROTECTED] wrote: Thanks, Igor. However, I tried it and it never showed up in the browser. Even more so, when I set a breakpoint to the onComponentTag-method, it never gets called. Is that correct? I only get this behavior when I am using the IndicatingAjaxButton--everything works fine with the regular buttons. Maybe I am missing something else here... Here's my code: /** * The panel with the form. */ public class SignInPanel extends Panel { public SignInPanel(final String id) { super(id); feedback.setOutputMarkupId(true); add(feedback); add(new SignInForm(signInForm)); } public final class SignInForm extends StatelessForm { private final ValueMap properties = new ValueMap(); public SignInForm(final String id) { super(id); FormComponent fc; fc = new RequiredTextField(username, new PropertyModel(properties, username)); fc.add(new InvalidIndicator()); fc.setOutputMarkupId(true); add(fc); fc = new PasswordTextField(password, new PropertyModel(properties, password)); fc.add(new InvalidIndicator()); fc.setOutputMarkupId(true); add(fc); AjaxFormValidatingBehavior.addToAllFormComponents(this, onsubmit); this.add(new IndicatingAjaxButton(submit, this) { @Override protected void onSubmit(AjaxRequestTarget target, Form form) { //perform sign in } @Override protected void onError(AjaxRequestTarget target, Form form) { target.addComponent(feedback); } }); } } /** * The validator. Thanks to Igor. */ public class InvalidIndicator extends AbstractBehavior { @Override public void onComponentTag(final Component component, final ComponentTag tag) { boolean valid = ((FormComponent)component).isValid(); if(!valid) { tag.getAttributes().put(class,invalid); } } } - Original Message From: Igor Vaynberg [EMAIL PROTECTED] To: users@wicket.apache.org Sent: Tuesday, September 23, 2008 5:50:08 PM Subject: Re: Adding HTML class=invalid after validating with IndicatingAjaxButton public class invalidindicator extends abstractbehavior { protected void oncomponenttag(component c, tag t) { boolean valid=((formcomponent)c).isvalid(); if (!valid) { tag.put(class,invalid); } } } formcomponent.add(new invalidindicator()); -igor On Tue, Sep 23, 2008 at 2:53 AM, cstein1206 [EMAIL PROTECTED] wrote: I basically want to achieve this: http://www.jroller.com/karthikg/entry/wicket_and_ajax but handle the validation only after the form has been submitted with an AjaxIndicatingButton instead of with the onblur as in the example. I think I tried too many things over the last couple of days and got totally confused now. Would anybody be so kind to help me out a bit? What do I need to add to the FormComponents so that they will be updated with an HTML-attribute class='invalid'? So far my form doesn't do that (I did setOutputMarkupId(true)). Thanks a ton! Chris -- View this message in context: http://www.nabble.com/Adding-HTML-class%3D%22invalid%22-after-validating-with-IndicatingAjaxButton-tp19624501p19624501.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED
Adding HTML class=invalid after validating with IndicatingAjaxButton
I basically want to achieve this: http://www.jroller.com/karthikg/entry/wicket_and_ajax but handle the validation only after the form has been submitted with an AjaxIndicatingButton instead of with the onblur as in the example. I think I tried too many things over the last couple of days and got totally confused now. Would anybody be so kind to help me out a bit? What do I need to add to the FormComponents so that they will be updated with an HTML-attribute class='invalid'? So far my form doesn't do that (I did setOutputMarkupId(true)). Thanks a ton! Chris -- View this message in context: http://www.nabble.com/Adding-HTML-class%3D%22invalid%22-after-validating-with-IndicatingAjaxButton-tp19624501p19624501.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Adding HTML class=invalid after validating with IndicatingAjaxButton
public class invalidindicator extends abstractbehavior { protected void oncomponenttag(component c, tag t) { boolean valid=((formcomponent)c).isvalid(); if (!valid) { tag.put(class,invalid); } } } formcomponent.add(new invalidindicator()); -igor On Tue, Sep 23, 2008 at 2:53 AM, cstein1206 [EMAIL PROTECTED] wrote: I basically want to achieve this: http://www.jroller.com/karthikg/entry/wicket_and_ajax but handle the validation only after the form has been submitted with an AjaxIndicatingButton instead of with the onblur as in the example. I think I tried too many things over the last couple of days and got totally confused now. Would anybody be so kind to help me out a bit? What do I need to add to the FormComponents so that they will be updated with an HTML-attribute class='invalid'? So far my form doesn't do that (I did setOutputMarkupId(true)). Thanks a ton! Chris -- View this message in context: http://www.nabble.com/Adding-HTML-class%3D%22invalid%22-after-validating-with-IndicatingAjaxButton-tp19624501p19624501.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Adding HTML class=invalid after validating with IndicatingAjaxButton
Thanks, Igor. However, I tried it and it never showed up in the browser. Even more so, when I set a breakpoint to the onComponentTag-method, it never gets called. Is that correct? I only get this behavior when I am using the IndicatingAjaxButton--everything works fine with the regular buttons. Maybe I am missing something else here... Here's my code: /** * The panel with the form. */ public class SignInPanel extends Panel { public SignInPanel(final String id) { super(id); feedback.setOutputMarkupId(true); add(feedback); add(new SignInForm(signInForm)); } public final class SignInForm extends StatelessForm { private final ValueMap properties = new ValueMap(); public SignInForm(final String id) { super(id); FormComponent fc; fc = new RequiredTextField(username, new PropertyModel(properties, username)); fc.add(new InvalidIndicator()); fc.setOutputMarkupId(true); add(fc); fc = new PasswordTextField(password, new PropertyModel(properties, password)); fc.add(new InvalidIndicator()); fc.setOutputMarkupId(true); add(fc); AjaxFormValidatingBehavior.addToAllFormComponents(this, onsubmit); this.add(new IndicatingAjaxButton(submit, this) { @Override protected void onSubmit(AjaxRequestTarget target, Form form) { //perform sign in } @Override protected void onError(AjaxRequestTarget target, Form form) { target.addComponent(feedback); } }); } } /** * The validator. Thanks to Igor. */ public class InvalidIndicator extends AbstractBehavior { @Override public void onComponentTag(final Component component, final ComponentTag tag) { boolean valid = ((FormComponent)component).isValid(); if(!valid) { tag.getAttributes().put(class,invalid); } } } - Original Message From: Igor Vaynberg [EMAIL PROTECTED] To: users@wicket.apache.org Sent: Tuesday, September 23, 2008 5:50:08 PM Subject: Re: Adding HTML class=invalid after validating with IndicatingAjaxButton public class invalidindicator extends abstractbehavior { protected void oncomponenttag(component c, tag t) { boolean valid=((formcomponent)c).isvalid(); if (!valid) { tag.put(class,invalid); } } } formcomponent.add(new invalidindicator()); -igor On Tue, Sep 23, 2008 at 2:53 AM, cstein1206 [EMAIL PROTECTED] wrote: I basically want to achieve this: http://www.jroller.com/karthikg/entry/wicket_and_ajax but handle the validation only after the form has been submitted with an AjaxIndicatingButton instead of with the onblur as in the example. I think I tried too many things over the last couple of days and got totally confused now. Would anybody be so kind to help me out a bit? What do I need to add to the FormComponents so that they will be updated with an HTML-attribute class='invalid'? So far my form doesn't do that (I did setOutputMarkupId(true)). Thanks a ton! Chris -- View this message in context: http://www.nabble.com/Adding-HTML-class%3D%22invalid%22-after-validating-with-IndicatingAjaxButton-tp19624501p19624501.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Adding HTML class=invalid after validating with IndicatingAjaxButton
Thanks, Igor. However, I tried it and it never showed up in the browser. Even more so, when I set a breakpoint to the onComponentTag-method, it never gets called. Is that correct? I only get this behavior when I am using the IndicatingAjaxButton--everything works fine with the regular buttons. Maybe I am missing something else here... Here's my code: /** * The panel with the form. */ public class SignInPanel extends Panel { public SignInPanel(final String id) { super(id); feedback.setOutputMarkupId(true); add(feedback); add(new SignInForm(signInForm)); } public final class SignInForm extends StatelessForm { private final ValueMap properties = new ValueMap(); public SignInForm(final String id) { super(id); FormComponent fc; fc = new RequiredTextField(username, new PropertyModel(properties, username)); fc.add(new InvalidIndicator()); fc.setOutputMarkupId(true); add(fc); fc = new PasswordTextField(password, new PropertyModel(properties, password)); fc.add(new InvalidIndicator()); fc.setOutputMarkupId(true); add(fc); AjaxFormValidatingBehavior.addToAllFormComponents(this, onsubmit); this.add(new IndicatingAjaxButton(submit, this) { @Override protected void onSubmit(AjaxRequestTarget target, Form form) { //perform sign in } @Override protected void onError(AjaxRequestTarget target, Form form) { target.addComponent(feedback); } }); } } /** * The validator. Thanks to Igor. */ public class InvalidIndicator extends AbstractBehavior { @Override public void onComponentTag(final Component component, final ComponentTag tag) { boolean valid = ((FormComponent)component).isValid(); if(!valid) { tag.getAttributes().put(class,invalid); } } } - Original Message From: Igor Vaynberg [EMAIL PROTECTED] To: users@wicket.apache.org Sent: Tuesday, September 23, 2008 5:50:08 PM Subject: Re: Adding HTML class=invalid after validating with IndicatingAjaxButton public class invalidindicator extends abstractbehavior { protected void oncomponenttag(component c, tag t) { boolean valid=((formcomponent)c).isvalid(); if (!valid) { tag.put(class,invalid); } } } formcomponent.add(new invalidindicator()); -igor On Tue, Sep 23, 2008 at 2:53 AM, cstein1206 [EMAIL PROTECTED] wrote: I basically want to achieve this: http://www.jroller.com/karthikg/entry/wicket_and_ajax but handle the validation only after the form has been submitted with an AjaxIndicatingButton instead of with the onblur as in the example. I think I tried too many things over the last couple of days and got totally confused now. Would anybody be so kind to help me out a bit? What do I need to add to the FormComponents so that they will be updated with an HTML-attribute class='invalid'? So far my form doesn't do that (I did setOutputMarkupId(true)). Thanks a ton! Chris -- View this message in context: http://www.nabble.com/Adding-HTML-class%3D%22invalid%22-after-validating-with-IndicatingAjaxButton-tp19624501p19624501.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Adding HTML class=invalid after validating with IndicatingAjaxButton
target.addComponent(feedback); target.addComponent(form); // you might have to add some div that is around the form, not sure if browsers support replacing form tag well -igor On Tue, Sep 23, 2008 at 1:39 PM, Chris Stein [EMAIL PROTECTED] wrote: Thanks, Igor. However, I tried it and it never showed up in the browser. Even more so, when I set a breakpoint to the onComponentTag-method, it never gets called. Is that correct? I only get this behavior when I am using the IndicatingAjaxButton--everything works fine with the regular buttons. Maybe I am missing something else here... Here's my code: /** * The panel with the form. */ public class SignInPanel extends Panel { public SignInPanel(final String id) { super(id); feedback.setOutputMarkupId(true); add(feedback); add(new SignInForm(signInForm)); } public final class SignInForm extends StatelessForm { private final ValueMap properties = new ValueMap(); public SignInForm(final String id) { super(id); FormComponent fc; fc = new RequiredTextField(username, new PropertyModel(properties, username)); fc.add(new InvalidIndicator()); fc.setOutputMarkupId(true); add(fc); fc = new PasswordTextField(password, new PropertyModel(properties, password)); fc.add(new InvalidIndicator()); fc.setOutputMarkupId(true); add(fc); AjaxFormValidatingBehavior.addToAllFormComponents(this, onsubmit); this.add(new IndicatingAjaxButton(submit, this) { @Override protected void onSubmit(AjaxRequestTarget target, Form form) { //perform sign in } @Override protected void onError(AjaxRequestTarget target, Form form) { target.addComponent(feedback); } }); } } /** * The validator. Thanks to Igor. */ public class InvalidIndicator extends AbstractBehavior { @Override public void onComponentTag(final Component component, final ComponentTag tag) { boolean valid = ((FormComponent)component).isValid(); if(!valid) { tag.getAttributes().put(class,invalid); } } } - Original Message From: Igor Vaynberg [EMAIL PROTECTED] To: users@wicket.apache.org Sent: Tuesday, September 23, 2008 5:50:08 PM Subject: Re: Adding HTML class=invalid after validating with IndicatingAjaxButton public class invalidindicator extends abstractbehavior { protected void oncomponenttag(component c, tag t) { boolean valid=((formcomponent)c).isvalid(); if (!valid) { tag.put(class,invalid); } } } formcomponent.add(new invalidindicator()); -igor On Tue, Sep 23, 2008 at 2:53 AM, cstein1206 [EMAIL PROTECTED] wrote: I basically want to achieve this: http://www.jroller.com/karthikg/entry/wicket_and_ajax but handle the validation only after the form has been submitted with an AjaxIndicatingButton instead of with the onblur as in the example. I think I tried too many things over the last couple of days and got totally confused now. Would anybody be so kind to help me out a bit? What do I need to add to the FormComponents so that they will be updated with an HTML-attribute class='invalid'? So far my form doesn't do that (I did setOutputMarkupId(true)). Thanks a ton! Chris -- View this message in context: http://www.nabble.com/Adding-HTML-class%3D%22invalid%22-after-validating-with-IndicatingAjaxButton-tp19624501p19624501.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]