Just add temporarily an AjaxButton to your form and see the generated HTML
for that button.
There you'll see the needed javascript.

I suggest you to leave the button and change your code to:
Wicket.$('%s').click(); } catch(err) { if (window.console !=
undefined) { console.log(err); } }", myAjaxButton.getMarkupId()));


On Thu, Jan 20, 2011 at 9:49 PM, Brown, Berlin [GCG-PFS] <
berlin.br...@primerica.com> wrote:

> This works, thanks.
>
> Another similar question based on your question.
>
> Can I use an ajax form submit, maybe using a wicket javascript utility.
>
> I guess I could use jquery but  does wicket have something available.
>
> E.g. as opposed to document.forms[xxx].submit().  Is there some generic
> ajax submit I could use.
>
> ...
>                this.add(new AjaxLink<Object>("nextLink") {
>
>
>                    @Override
>                    public void onClick(final AjaxRequestTarget target)
> {
>                        // Find the dynamic form on the page.
>                        final Object objAtStopTraversal =
> HomePage.this.visitChildren(new FindFormVisitor());
>                        if (objAtStopTraversal instanceof Form<?>) {
>                            // Form found, invoke javascript submit
>                            final Form<?> form = (Form<?>)
> objAtStopTraversal;
>                            target.appendJavascript(String.format("try {
> document.forms['%s'].submit(); } catch(err) { if (window.console !=
> undefined) { console.log(err); } }", form.getMarkupId()));
>                        }
>                    }
>                } );
>
> -----Original Message-----
> From: Martin Grigorov [mailto:mgrigo...@apache.org]
> Sent: Thursday, January 20, 2011 9:01 AM
> To: users@wicket.apache.org
> Subject: Re: Submit form from other form onClick
>
> you can submit any form with pure javascript:
> document.getElementById('myform').submit();
> this will call the respective myForm.onSubmit() method at the server
> side
>
> at server side you may call directly your methods e.g.
> new Form() {onSubmit() { myService.do(); }} new AjaxLink() {onClick() {
> myService.do(); }} no need to call Wicket methods
>
> On Thu, Jan 20, 2011 at 2:49 PM, Brown, Berlin [GCG-PFS] <
> berlin.br...@primerica.com> wrote:
>
> > Is there a way to manually submit a form.  E.g. normally we would have
>
> > action handler methods onSubmit (on a button or a form).
> >
> > E.g.
> >
> > new AjaxLink() {
> >   onClick() {
> >     someOtherForm.submit();
> >   }
> > }
> >
> > Berlin Brown
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

Reply via email to