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 <mase...@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:jer...@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 <mase...@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:jer...@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 <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 >> > >> > >> >> --------------------------------------------------------------------- >> 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 > > -- 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-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org