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: [email protected]
> 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]