You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Martin Asenov <mA...@velti.com> on 2010/01/18 10:17:12 UTC

submit a form from outside of it

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


RE: submit a form from outside of it

Posted by Martin Asenov <mA...@velti.com>.
it's not working... The problem probably is that the form has it's own generated markup id and the button looks for the form with markup id from the one that comes in the AjaxButton's constructor as an argument. Because I have:

submitButton = new AjaxButton("submit_button", formPanel.getForm()) {
	protected void onSubmit(ART target) {
		do smth
	}
}

and because I display different panels with different forms ( especially their markupId ) it can't find the current one by it's markup id. I just can't think of a workaround to solve this.

Please, if someone has a better idea, it would be great to share it...

Best Regards,
Martin 

-----Original Message-----
From: Martin Asenov [mailto:mAsenov@velti.com] 
Sent: Monday, January 18, 2010 3:33 PM
To: users@wicket.apache.org
Subject: RE: submit a form from outside of it

Yes, Bert, it's accessible. The way you proposed comes up with:

ERROR: Wicket.Ajax.Call.submitFormById: Trying to submit form with id 'form49a' that is not in document.

in the ajax debug. But the form is in the document. Probably it has dynamic markup id and I should try making it persistent.

Thanks,

-----Original Message-----
From: Bert [mailto:taseroth@gmail.com] 
Sent: Monday, January 18, 2010 2:17 PM
To: users@wicket.apache.org
Subject: Re: submit a form from outside of it

I 'm not sure i completely understand your requirement, but the
AjaxButton too has a constructor
with a Form as parameter. Would it be possible to access the form when
creating the button?

Bert

On Mon, Jan 18, 2010 at 13:11, Martin Asenov <mA...@velti.com> wrote:
> Thanks Bert, but I use a button... I need to have the button in the page, because it does the same for any form. I want to have code re-usage.  But however my abstract MyFormPanel does not have relevant markup, so I can't include the buttons there, it would be nice, but I can not. I just want to avoid having the very same buttons and markup in every subclass of MyFormPanel...
>
> Can anyone please give further assist?

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


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


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


RE: submit a form from outside of it

Posted by Martin Asenov <mA...@velti.com>.
Yes, Bert, it's accessible. The way you proposed comes up with:

ERROR: Wicket.Ajax.Call.submitFormById: Trying to submit form with id 'form49a' that is not in document.

in the ajax debug. But the form is in the document. Probably it has dynamic markup id and I should try making it persistent.

Thanks,

-----Original Message-----
From: Bert [mailto:taseroth@gmail.com] 
Sent: Monday, January 18, 2010 2:17 PM
To: users@wicket.apache.org
Subject: Re: submit a form from outside of it

I 'm not sure i completely understand your requirement, but the
AjaxButton too has a constructor
with a Form as parameter. Would it be possible to access the form when
creating the button?

Bert

On Mon, Jan 18, 2010 at 13:11, Martin Asenov <mA...@velti.com> wrote:
> Thanks Bert, but I use a button... I need to have the button in the page, because it does the same for any form. I want to have code re-usage.  But however my abstract MyFormPanel does not have relevant markup, so I can't include the buttons there, it would be nice, but I can not. I just want to avoid having the very same buttons and markup in every subclass of MyFormPanel...
>
> Can anyone please give further assist?

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


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


Re: submit a form from outside of it

Posted by Bert <ta...@gmail.com>.
I 'm not sure i completely understand your requirement, but the
AjaxButton too has a constructor
with a Form as parameter. Would it be possible to access the form when
creating the button?

Bert

On Mon, Jan 18, 2010 at 13:11, Martin Asenov <mA...@velti.com> wrote:
> Thanks Bert, but I use a button... I need to have the button in the page, because it does the same for any form. I want to have code re-usage.  But however my abstract MyFormPanel does not have relevant markup, so I can't include the buttons there, it would be nice, but I can not. I just want to avoid having the very same buttons and markup in every subclass of MyFormPanel...
>
> Can anyone please give further assist?

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


RE: submit a form from outside of it

Posted by Martin Asenov <mA...@velti.com>.
Thanks Bert, but I use a button... I need to have the button in the page, because it does the same for any form. I want to have code re-usage.  But however my abstract MyFormPanel does not have relevant markup, so I can't include the buttons there, it would be nice, but I can not. I just want to avoid having the very same buttons and markup in every subclass of MyFormPanel...

Can anyone please give further assist? 

Thank you,
Martin

-----Original Message-----
From: Bert [mailto:taseroth@gmail.com] 
Sent: Monday, January 18, 2010 12:38 PM
To: users@wicket.apache.org
Subject: Re: submit a form from outside of it

Not sure here, but the AjaxSubmitLink has an constructor that lets you
pass in the form it should work on.

Bert

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


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


Re: submit a form from outside of it

Posted by Bert <ta...@gmail.com>.
Not sure here, but the AjaxSubmitLink has an constructor that lets you
pass in the form it should work on.

Bert

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


RE: submit a form from outside of it

Posted by Martin Asenov <mA...@velti.com>.
Hi namesake! :-) 

Unfortunately this is not what I need since as I said panels do not have reference to their parent page. Anyway thanks for your time!

After all I put the feedbackpanel in every single subpanel (well , only in the markup, because my abstract parent panel defines it in code).

Thank you all!

Best Regards,
Martin

-----Original Message-----
From: Martijn Dashorst [mailto:martijn.dashorst@gmail.com] 
Sent: Monday, January 18, 2010 7:12 PM
To: users@wicket.apache.org
Subject: Re: submit a form from outside of it

IFeedbackProvider {
    FeedbackPanel getFeedbackPanel();
}

MyPage extends Webpage implements IFeedbackProvider {
    public MyPage() {
        add(new FeedbackPanel("feedback"));
        add(new MySubPanel("panel", this));
    }
    @Override
    FeedbackPanel getFeedbackPanel() {
        return get("feedback");
    }
}

MySubPanel extends Panel {
    private IFeedbackProvider feedback;
    public MySubPanel(String id, IFeedbackProvider provider) {
        super(id);
        this.feedback = provider;

        ... some ajax handler ...
        onSubmit(AjaxRequestTarget t) {
             t.addComponent(feedback.getFeedbackPanel());
        }
    }
}



On Mon, Jan 18, 2010 at 5:52 PM, Martin Asenov <mA...@velti.com> wrote:
> Yes, but in my case the panels don't even know about the parent - they don't have a reference to it. I've got to think of some workaround on this one.
>
> Thanks for your time,
> Martin
>
> -----Original Message-----
> From: Jeremy Thomerson [mailto:jeremy@wickettraining.com]
> Sent: Monday, January 18, 2010 6:45 PM
> To: users@wicket.apache.org
> Subject: Re: submit a form from outside of it
>
> Ah - I see.  Yeah - you just have to roll your own option for this now.  I'd
> just recommend some sort of listener pattern - something like adding a void
> formSubmitted(form, requesttarget) method on the page that child forms can
> call.  Then the pages can do whatever they need with it.
>
> --
> Jeremy Thomerson
> http://www.wickettraining.com
>
>
>
> On Mon, Jan 18, 2010 at 10:40 AM, Martin Asenov <mA...@velti.com> wrote:
>
>> Yeah, Jeremy, that's pretty clear. I was saying that I can't know in the
>> parent page when the submit button is pressed , so that I can say
>> target.addComponent(feed); when feed is in parent page...
>>
>> BR,
>> Martin
>>
>> -----Original Message-----
>> From: Jeremy Thomerson [mailto:jeremy@wickettraining.com]
>> Sent: Monday, January 18, 2010 6:37 PM
>> To: users@wicket.apache.org
>> Subject: Re: submit a form from outside of it
>>
>> 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 <mA...@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:jeremy@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 <
>> > alexandrubarbat@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 <mA...@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:alexandrubarbat@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 <mA...@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-unsubscribe@wicket.apache.org
>> > > > For additional commands, e-mail: users-help@wicket.apache.org
>> > > >
>> > > >
>> > >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > For additional commands, e-mail: users-help@wicket.apache.org
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.4 increases type safety for web applications
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.4.4

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


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


Re: submit a form from outside of it

Posted by Martijn Dashorst <ma...@gmail.com>.
IFeedbackProvider {
    FeedbackPanel getFeedbackPanel();
}

MyPage extends Webpage implements IFeedbackProvider {
    public MyPage() {
        add(new FeedbackPanel("feedback"));
        add(new MySubPanel("panel", this));
    }
    @Override
    FeedbackPanel getFeedbackPanel() {
        return get("feedback");
    }
}

MySubPanel extends Panel {
    private IFeedbackProvider feedback;
    public MySubPanel(String id, IFeedbackProvider provider) {
        super(id);
        this.feedback = provider;

        ... some ajax handler ...
        onSubmit(AjaxRequestTarget t) {
             t.addComponent(feedback.getFeedbackPanel());
        }
    }
}



On Mon, Jan 18, 2010 at 5:52 PM, Martin Asenov <mA...@velti.com> wrote:
> Yes, but in my case the panels don't even know about the parent - they don't have a reference to it. I've got to think of some workaround on this one.
>
> Thanks for your time,
> Martin
>
> -----Original Message-----
> From: Jeremy Thomerson [mailto:jeremy@wickettraining.com]
> Sent: Monday, January 18, 2010 6:45 PM
> To: users@wicket.apache.org
> Subject: Re: submit a form from outside of it
>
> Ah - I see.  Yeah - you just have to roll your own option for this now.  I'd
> just recommend some sort of listener pattern - something like adding a void
> formSubmitted(form, requesttarget) method on the page that child forms can
> call.  Then the pages can do whatever they need with it.
>
> --
> Jeremy Thomerson
> http://www.wickettraining.com
>
>
>
> On Mon, Jan 18, 2010 at 10:40 AM, Martin Asenov <mA...@velti.com> wrote:
>
>> Yeah, Jeremy, that's pretty clear. I was saying that I can't know in the
>> parent page when the submit button is pressed , so that I can say
>> target.addComponent(feed); when feed is in parent page...
>>
>> BR,
>> Martin
>>
>> -----Original Message-----
>> From: Jeremy Thomerson [mailto:jeremy@wickettraining.com]
>> Sent: Monday, January 18, 2010 6:37 PM
>> To: users@wicket.apache.org
>> Subject: Re: submit a form from outside of it
>>
>> 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 <mA...@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:jeremy@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 <
>> > alexandrubarbat@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 <mA...@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:alexandrubarbat@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 <mA...@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-unsubscribe@wicket.apache.org
>> > > > For additional commands, e-mail: users-help@wicket.apache.org
>> > > >
>> > > >
>> > >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > For additional commands, e-mail: users-help@wicket.apache.org
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.4 increases type safety for web applications
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.4.4

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


RE: submit a form from outside of it

Posted by Martin Asenov <mA...@velti.com>.
Yes, but in my case the panels don't even know about the parent - they don't have a reference to it. I've got to think of some workaround on this one.

Thanks for your time,
Martin

-----Original Message-----
From: Jeremy Thomerson [mailto:jeremy@wickettraining.com] 
Sent: Monday, January 18, 2010 6:45 PM
To: users@wicket.apache.org
Subject: Re: submit a form from outside of it

Ah - I see.  Yeah - you just have to roll your own option for this now.  I'd
just recommend some sort of listener pattern - something like adding a void
formSubmitted(form, requesttarget) method on the page that child forms can
call.  Then the pages can do whatever they need with it.

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



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

> Yeah, Jeremy, that's pretty clear. I was saying that I can't know in the
> parent page when the submit button is pressed , so that I can say
> target.addComponent(feed); when feed is in parent page...
>
> BR,
> Martin
>
> -----Original Message-----
> From: Jeremy Thomerson [mailto:jeremy@wickettraining.com]
> Sent: Monday, January 18, 2010 6:37 PM
> To: users@wicket.apache.org
> Subject: Re: submit a form from outside of it
>
> 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 <mA...@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:jeremy@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 <
> > alexandrubarbat@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 <mA...@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:alexandrubarbat@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 <mA...@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-unsubscribe@wicket.apache.org
> > > > For additional commands, e-mail: users-help@wicket.apache.org
> > > >
> > > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: submit a form from outside of it

Posted by Jeremy Thomerson <je...@wickettraining.com>.
Ah - I see.  Yeah - you just have to roll your own option for this now.  I'd
just recommend some sort of listener pattern - something like adding a void
formSubmitted(form, requesttarget) method on the page that child forms can
call.  Then the pages can do whatever they need with it.

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



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

> Yeah, Jeremy, that's pretty clear. I was saying that I can't know in the
> parent page when the submit button is pressed , so that I can say
> target.addComponent(feed); when feed is in parent page...
>
> BR,
> Martin
>
> -----Original Message-----
> From: Jeremy Thomerson [mailto:jeremy@wickettraining.com]
> Sent: Monday, January 18, 2010 6:37 PM
> To: users@wicket.apache.org
> Subject: Re: submit a form from outside of it
>
> 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 <mA...@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:jeremy@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 <
> > alexandrubarbat@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 <mA...@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:alexandrubarbat@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 <mA...@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-unsubscribe@wicket.apache.org
> > > > For additional commands, e-mail: users-help@wicket.apache.org
> > > >
> > > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

RE: submit a form from outside of it

Posted by Martin Asenov <mA...@velti.com>.
Yeah, Jeremy, that's pretty clear. I was saying that I can't know in the parent page when the submit button is pressed , so that I can say target.addComponent(feed); when feed is in parent page...

BR,
Martin

-----Original Message-----
From: Jeremy Thomerson [mailto:jeremy@wickettraining.com] 
Sent: Monday, January 18, 2010 6:37 PM
To: users@wicket.apache.org
Subject: Re: submit a form from outside of it

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 <mA...@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:jeremy@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 <
> alexandrubarbat@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 <mA...@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:alexandrubarbat@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 <mA...@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-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: submit a form from outside of it

Posted by Jeremy Thomerson <je...@wickettraining.com>.
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 <mA...@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:jeremy@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 <
> alexandrubarbat@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 <mA...@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:alexandrubarbat@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 <mA...@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-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

RE: submit a form from outside of it

Posted by Martin Asenov <mA...@velti.com>.
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:jeremy@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 <alexandrubarbat@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 <mA...@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:alexandrubarbat@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 <mA...@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-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>

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


Re: submit a form from outside of it

Posted by Jeremy Thomerson <je...@wickettraining.com>.
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 <alexandrubarbat@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 <mA...@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:alexandrubarbat@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 <mA...@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-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>

Re: submit a form from outside of it

Posted by Alexandru Barbat <al...@gmail.com>.
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 <mA...@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:alexandrubarbat@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 <mA...@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-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

RE: submit a form from outside of it

Posted by Martin Asenov <mA...@velti.com>.
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:alexandrubarbat@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 <mA...@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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: submit a form from outside of it

Posted by Alexandru Barbat <al...@gmail.com>.
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 <mA...@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
>
>