On-demand component initialization
Hi, I'm trying to create a ModalWindow, something similar to this example: http://wicketstuff.org/wicket14/nested/?wicket:bookmarkablePage=:org.apache.wicket.examples.ajax.builtin.modal.ModalWindowPage If I create the modalwindow like this: final ModalWindow modal = new ModalWindow(modal); modal.setContent(new RegisterPanel(modal)); modal.setTitle(Registration); modal.setCookieName(register); add(new AjaxLink(showModal) { @Override public void onClick(AjaxRequestTarget target) { modal.show(target); } }); add(modal); then when I construct the page containing this modalwindow, I also will construct the modalwindow content, but the user can just decide to not to click on this link, so skip the modal, and then I have an unnecessary constructed panel. So I've played a bit with my RegisterPanel, and moved all of my logic to onInitialize (because it's called before onBeforeRender), to initialize my stuff there, but it looks like onInitialize is still called without user action. If I put everything into onBeforeRender, then I can guarantee, that the constructing logic runs on-demand, but then I will have problems when user wants to reopen the window. I could create a field to check whether I already initialized the component in oBeforeRender, but that sounds like a hack. How can I solve this issue elegantly? Thanks, Peter - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: On-demand component initialization
then when I construct the page containing this modalwindow, I also will construct the modalwindow content, but the user can just decide to not to click on this link, so skip the modal, and then I have an unnecessary constructed panel. Yeah.. you can construct panel in onClick before .show(); Also make note that you can re-use same modal window with various different content always using setContent or setTitle on-fly. ** Martin Thanks, Peter - 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: On-demand component initialization
You can set content for modal within onClick method. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/On-demand-component-initialization-tp3020334p3020343.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: On-demand component initialization
Yeah, but then I would create new panel for every single click on that link. I know it's a bit edge-case, but still... So I can't achieve this without some own initialization logic? Thanks for your replies. Regards, Peter 2010-10-30 16:48 keltezéssel, Alexander Morozov írta: You can set content for modal within onClick method. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: On-demand component initialization
Hi! Yeah, but then I would create new panel for every single click on that link. I know it's a bit edge-case, but still... So I can't achieve this without some own initialization logic? You don't need to create new panel, just use lazy initialization. modalWidnow.setContent(getContentPanel()); getContentPanel() { if (contentPanel == null) { contentpanel = new ... } return contentPanel; } ** Martin Thanks for your replies. Regards, Peter 2010-10-30 16:48 keltezéssel, Alexander Morozov írta: You can set content for modal within onClick method. - 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