Re: Reusing forms in different contexts
Hi Martin, Thanks for the tip! This is an interesting approach as well. On 22/02/2012 2:49 AM, Martin Grigorov wrote: HI Bertrand, I'm not quite sure whether this is your concern but take a look at org.apache.wicket.markup.html.tree.BaseTree#newLink() It uses LinkType to decide what kind of Link to create. You can use the same approach. On Wed, Feb 22, 2012 at 6:12 AM, Bertrand Guay-Paquet ber...@step.polymtl.ca wrote: Thanks Igor. This is actually very close to what I used as my first approach. The problem I had then was that depending on the context in which the panel is used, the component must be one of the following: 1-A Link/Button, like in your code 2-A BookmarkablePageLink 3-An AjaxLink (ajax replacement, close modal window, etc.) In your example, myformpanel can only work with case #1. This is essentially the problem that has me scratching my head. Regards, Bertrand On 21/02/2012 7:04 PM, Igor Vaynberg wrote: *abstract* class myformpanel extends panel { public myformpanel(string id) { add(new button(save) { onsubmit() { *onsave(model);* });} *protected abstract void onsave(imodel);* } add(new myformpanel(panel) { protected void onsave(imodel) { // do stuff setResponsePage() or replaceWith() or whatever you want }} -igor On Tue, Feb 21, 2012 at 3:53 PM, Bertrand Guay-Paquet ber...@step.polymtl.cawrote: Hi, I want to reuse the same form panels in different contexts and would like to know how fellow Wicket users achieve this. The core of the problem is how to let the user of a form panel specify where to navigate when the form is submitted or canceled. There are multiple possibilities for this: -setResponsePage a bookmarkable page -setResponsePage a page instance (to go back to the previous page for example) -replace the form panel via ajax -close a modal window via ajax -bubble a Wicket event I've tried 2 approaches up to now : -some form of markup inheritance. This requires subclassing the form panel at each usage site. -navigation factories provided to the form panel which are responsible for populating it with the proper submit and cancel links/buttons. Both of these approaches are kludgy and I have the feeling there has to be a better way. Which way is the Wicket way to let the user of a panel customize its navigation? Thanks, Bertrand - 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
Reusing forms in different contexts
Hi, I want to reuse the same form panels in different contexts and would like to know how fellow Wicket users achieve this. The core of the problem is how to let the user of a form panel specify where to navigate when the form is submitted or canceled. There are multiple possibilities for this: -setResponsePage a bookmarkable page -setResponsePage a page instance (to go back to the previous page for example) -replace the form panel via ajax -close a modal window via ajax -bubble a Wicket event I've tried 2 approaches up to now : -some form of markup inheritance. This requires subclassing the form panel at each usage site. -navigation factories provided to the form panel which are responsible for populating it with the proper submit and cancel links/buttons. Both of these approaches are kludgy and I have the feeling there has to be a better way. Which way is the Wicket way to let the user of a panel customize its navigation? Thanks, Bertrand - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Reusing forms in different contexts
*abstract* class myformpanel extends panel { public myformpanel(string id) { add(new button(save) { onsubmit() { *onsave(model);* });} *protected abstract void onsave(imodel);* } add(new myformpanel(panel) { protected void onsave(imodel) { // do stuff setResponsePage() or replaceWith() or whatever you want }} -igor On Tue, Feb 21, 2012 at 3:53 PM, Bertrand Guay-Paquet ber...@step.polymtl.ca wrote: Hi, I want to reuse the same form panels in different contexts and would like to know how fellow Wicket users achieve this. The core of the problem is how to let the user of a form panel specify where to navigate when the form is submitted or canceled. There are multiple possibilities for this: -setResponsePage a bookmarkable page -setResponsePage a page instance (to go back to the previous page for example) -replace the form panel via ajax -close a modal window via ajax -bubble a Wicket event I've tried 2 approaches up to now : -some form of markup inheritance. This requires subclassing the form panel at each usage site. -navigation factories provided to the form panel which are responsible for populating it with the proper submit and cancel links/buttons. Both of these approaches are kludgy and I have the feeling there has to be a better way. Which way is the Wicket way to let the user of a panel customize its navigation? Thanks, Bertrand - 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
Re: Reusing forms in different contexts
Thanks Igor. This is actually very close to what I used as my first approach. The problem I had then was that depending on the context in which the panel is used, the component must be one of the following: 1-A Link/Button, like in your code 2-A BookmarkablePageLink 3-An AjaxLink (ajax replacement, close modal window, etc.) In your example, myformpanel can only work with case #1. This is essentially the problem that has me scratching my head. Regards, Bertrand On 21/02/2012 7:04 PM, Igor Vaynberg wrote: *abstract* class myformpanel extends panel { public myformpanel(string id) { add(new button(save) { onsubmit() { *onsave(model);* });} *protected abstract void onsave(imodel);* } add(new myformpanel(panel) { protected void onsave(imodel) { // do stuff setResponsePage() or replaceWith() or whatever you want }} -igor On Tue, Feb 21, 2012 at 3:53 PM, Bertrand Guay-Paquet ber...@step.polymtl.ca wrote: Hi, I want to reuse the same form panels in different contexts and would like to know how fellow Wicket users achieve this. The core of the problem is how to let the user of a form panel specify where to navigate when the form is submitted or canceled. There are multiple possibilities for this: -setResponsePage a bookmarkable page -setResponsePage a page instance (to go back to the previous page for example) -replace the form panel via ajax -close a modal window via ajax -bubble a Wicket event I've tried 2 approaches up to now : -some form of markup inheritance. This requires subclassing the form panel at each usage site. -navigation factories provided to the form panel which are responsible for populating it with the proper submit and cancel links/buttons. Both of these approaches are kludgy and I have the feeling there has to be a better way. Which way is the Wicket way to let the user of a panel customize its navigation? Thanks, Bertrand - 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
Re: Reusing forms in different contexts
HI Bertrand, I'm not quite sure whether this is your concern but take a look at org.apache.wicket.markup.html.tree.BaseTree#newLink() It uses LinkType to decide what kind of Link to create. You can use the same approach. On Wed, Feb 22, 2012 at 6:12 AM, Bertrand Guay-Paquet ber...@step.polymtl.ca wrote: Thanks Igor. This is actually very close to what I used as my first approach. The problem I had then was that depending on the context in which the panel is used, the component must be one of the following: 1-A Link/Button, like in your code 2-A BookmarkablePageLink 3-An AjaxLink (ajax replacement, close modal window, etc.) In your example, myformpanel can only work with case #1. This is essentially the problem that has me scratching my head. Regards, Bertrand On 21/02/2012 7:04 PM, Igor Vaynberg wrote: *abstract* class myformpanel extends panel { public myformpanel(string id) { add(new button(save) { onsubmit() { *onsave(model);* });} *protected abstract void onsave(imodel);* } add(new myformpanel(panel) { protected void onsave(imodel) { // do stuff setResponsePage() or replaceWith() or whatever you want }} -igor On Tue, Feb 21, 2012 at 3:53 PM, Bertrand Guay-Paquet ber...@step.polymtl.ca wrote: Hi, I want to reuse the same form panels in different contexts and would like to know how fellow Wicket users achieve this. The core of the problem is how to let the user of a form panel specify where to navigate when the form is submitted or canceled. There are multiple possibilities for this: -setResponsePage a bookmarkable page -setResponsePage a page instance (to go back to the previous page for example) -replace the form panel via ajax -close a modal window via ajax -bubble a Wicket event I've tried 2 approaches up to now : -some form of markup inheritance. This requires subclassing the form panel at each usage site. -navigation factories provided to the form panel which are responsible for populating it with the proper submit and cancel links/buttons. Both of these approaches are kludgy and I have the feeling there has to be a better way. Which way is the Wicket way to let the user of a panel customize its navigation? Thanks, Bertrand - 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 -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org