What do you mean - you can't tell which button was pressed?

Just add an onSubmit to the button and inside of it, add your feedback
message.  or call getPage().info("..."), etc.  Then allow the onSubmit of
the form to do its thing.

--
Jeremy Thomerson
http://www.wickettraining.com



On Mon, Jan 18, 2010 at 10:35 AM, Martin Asenov <mase...@velti.com> wrote:

> Thank you both for the replies! After all I put the buttons in myFormPanel.
> But this way I can't know when the submit and cancel buttons are pressed so
> that I can render the feedback that is located in the parent page.
>
> Should I think of some listener?
>
> BR,
> Martin
>
> -----Original Message-----
> From: Jeremy Thomerson [mailto:jer...@wickettraining.com]
> Sent: Monday, January 18, 2010 6:31 PM
> To: users@wicket.apache.org
> Subject: Re: submit a form from outside of it
>
> Or wrap the outer page in a form so that any nested forms work with your
> out-of-place submit button.
>
> --
> Jeremy Thomerson
> http://www.wickettraining.com
>
>
>
> On Mon, Jan 18, 2010 at 9:43 AM, Alexandru Barbat <
> alexandrubar...@gmail.com
> > wrote:
>
> > I think you have to pass the form to the behavior in some way or you can
> do
> > something like this..but it is ugly in some way :)
> >
> >
> > 1. in the form panel
> >
> >  AjaxFormSubmitBehavior behave = new AjaxFormSubmitBehavior(form,
> > "onchange") {
> >            ...
> >            public void renderHead(IHeaderResponse response) {
> >                super.renderHead(response);
> >                response.renderJavascript("function submit_my_form(){\n" +
> > getEventHandler().toString() + "\n}", "submit_my_form");
> >            }
> >        };
> >
> > form.add(behave);
> >
> >
> > ...
> >
> > 2. anywhere in the page
> >
> > and your button will look like this:
> >
> > <input type="button" value="my_button" onclick="submit_my_form()"/>
> >
> >
> >
> >
> > On Mon, Jan 18, 2010 at 12:22 PM, Martin Asenov <mase...@velti.com>
> wrote:
> >
> > > Hi, Alexandru, thanks for the quick reply.
> > >
> > > I get
> > >
> > > java.lang.IllegalStateException: form was not specified in the
> > constructor
> > > and cannot be found in the hierarchy of the component this behavior is
> > > attached to
> > >
> > > the form is located in the same page and displayed, but it's actually
> > > placed within a panel that is a child of the page. :-(
> > >
> > > BR,
> > >
> > > -----Original Message-----
> > > From: Alexandru Barbat [mailto:alexandrubar...@gmail.com]
> > > Sent: Monday, January 18, 2010 11:26 AM
> > > To: users@wicket.apache.org
> > > Subject: Re: submit a form from outside of it
> > >
> > > Hi,
> > >
> > > Try this:
> > >
> > > AjaxFormSubmitBehavior behave = new AjaxFormSubmitBehavior(myForm,
> > > "onclick") {
> > >            protected void onSubmit(AjaxRequestTarget target) {
> > >                //do what you have to do
> > >            }
> > >
> > >
> > >        };
> > >
> > >
> > > Button submitButton = new Button("submitButton");
> > >
> > > submitButton.add(behave);
> > >
> > > ...
> > >
> > > Alexandru
> > >
> > > 2010/1/18 Martin Asenov <mase...@velti.com>
> > >
> > > > Hello, everyone!
> > > >
> > > > I have a form that has validation and so on, but the main difference
> to
> > > > ordinary forms is that my form does not contain it's submit button.
> > It's
> > > > located in a parent, in my case a web page.
> > > >
> > > > I'm wondering how can I force the form submitting from the page. The
> > code
> > > > is
> > > >
> > > > submitButton = new AjaxButton("submit_button) {
> > > >         protected void onSubmit(AjaxRequestTarget target, Form<?>
> form)
> > {
> > > >                   myForm.processForm();
> > > >         }
> > > > };
> > > >
> > > > The method processForm() in myForm just calls process();
> > > >
> > > > But nothing happens, looks like I'm missing something...
> > > >
> > > > Thanks,
> > > > Martin
> > > >
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > > For additional commands, e-mail: users-h...@wicket.apache.org
> > >
> > >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

Reply via email to