Avoid getObject on Model if component not rendered
Hello, anyone have an idea how to avoid getting model object if component is not rendered? ListModelCustomUser usersListModel = new ListModelCustomUser() { private static final long serialVersionUID = -4520573537970008038L; @Override public ListCustomUser getObject() { return customUserDetailsService.loadAllUsers(); } }; final DropDownChoiceCustomUser usersChoice = new DropDownChoiceCustomUser(usersList, customUserModel, usersListModel, new ChoiceRendererCustomUser(username)); usersChoice.setNullValid(false); usersChoice.setModelObject(usersChoice.getChoices().get(0)); usersChoice.add(new AjaxFormComponentUpdatingBehavior(onchange) { private static final long serialVersionUID = 7L; @Override protected void onUpdate(AjaxRequestTarget target) { target.addComponent(customUserForm); } }); add(usersChoice); In some cases, usersChoice component is not rendered, becouse it is in SecuredPanel, witch shown only for admin users. But when page loading, this always calls secured service. I can make it unsecured to solve the problem, and call this service always, but maby there is a way to stop calling the service? :D Any ideas? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Avoid-getObject-on-Model-if-component-not-rendered-tp3006125p3006125.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: Avoid getObject on Model if component not rendered
On Thu, Oct 21, 2010 at 2:07 PM, meduolis meduol...@gmail.com wrote: usersChoice.setModelObject(usersChoice.getChoices().get(0)); You're calling it yourself. The line above is the culprit. -- Jeremy Thomerson http://wickettraining.com *Need a CMS for Wicket? Use Brix! http://brixcms.org*
Re: Avoid getObject on Model if component not rendered
Oh, ..., thanks for a sharp eye ;)..Then I will need to find another way how to get rid of that default drop down value Choose one. Thank you -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Avoid-getObject-on-Model-if-component-not-rendered-tp3006125p3006137.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: Avoid getObject on Model if component not rendered
Create and add the DropDownChoice in onInitialize(). If the component is not rendered then that method will not be called (untested) @Override protected void onInitialize() { super.onInitialize(); final DropDownChoiceCustomUser usersChoice = new DropDownChoiceCustomUser(usersList, customUserModel, usersListModel, new ChoiceRendererCustomUser(username)); usersChoice.setNullValid(false); usersChoice.setModelObject(usersChoice.getChoices().get(0)); usersChoice.add(new AjaxFormComponentUpdatingBehavior(onchange) { ... Regards Hans ___ WEB.DE DSL Doppel-Flat ab 19,99 euro;/mtl.! Jetzt auch mit gratis Notebook-Flat! http://produkte.web.de/go/DSL_Doppel_Flatrate/2 - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Avoid getObject on Model if component not rendered
Or, just set the default value in onConfigure of the dropdownchoice itself, which will not be called if the ddc is not visible. On Thu, Oct 21, 2010 at 2:52 PM, Hans Lesmeister le...@web.de wrote: Create and add the DropDownChoice in onInitialize(). If the component is not rendered then that method will not be called (untested) @Override protected void onInitialize() { super.onInitialize(); final DropDownChoiceCustomUser usersChoice = new DropDownChoiceCustomUser(usersList, customUserModel, usersListModel, new ChoiceRendererCustomUser(username)); usersChoice.setNullValid(false); usersChoice.setModelObject(usersChoice.getChoices().get(0)); usersChoice.add(new AjaxFormComponentUpdatingBehavior(onchange) { ... Regards Hans ___ WEB.DE DSL Doppel-Flat ab 19,99 euro;/mtl.! Jetzt auch mit gratis Notebook-Flat! http://produkte.web.de/go/DSL_Doppel_Flatrate/2 - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Jeremy Thomerson http://wickettraining.com *Need a CMS for Wicket? Use Brix! http://brixcms.org*
Re: Avoid getObject on Model if component not rendered
Am 21.10.10 21:07 schrieb meduolis unter meduol...@gmail.com: final DropDownChoiceCustomUser usersChoice = new DropDownChoiceCustomUser(usersList, customUserModel, usersListModel, new ChoiceRendererCustomUser(username)); usersChoice.setNullValid(false); usersChoice.setModelObject(usersChoice.getChoices().get(0)); usersChoice.add(new AjaxFormComponentUpdatingBehavior(onchange) { Create and add the DropDownChoice in onInitialize(). If the component is not rendered then that method will not be called (untested) Regards Hans
Re: Avoid getObject on Model if component not rendered
AFAIK onConfigure() is _always_ called, also when a Component is invisible; If I recall correctly this was done to remove the callOnBeforeRenderIfInvisble() method and switching visibility in onBeforeRender(). Bas - Original Message - From: Jeremy Thomerson jer...@wickettraining.com To: users@wicket.apache.org Sent: Thursday, October 21, 2010 9:56 PM Subject: Re: Avoid getObject on Model if component not rendered Or, just set the default value in onConfigure of the dropdownchoice itself, which will not be called if the ddc is not visible. On Thu, Oct 21, 2010 at 2:52 PM, Hans Lesmeister le...@web.de wrote: Create and add the DropDownChoice in onInitialize(). If the component is not rendered then that method will not be called (untested) @Override protected void onInitialize() { super.onInitialize(); final DropDownChoiceCustomUser usersChoice = new DropDownChoiceCustomUser(usersList, customUserModel, usersListModel, new ChoiceRendererCustomUser(username)); usersChoice.setNullValid(false); usersChoice.setModelObject(usersChoice.getChoices().get(0)); usersChoice.add(new AjaxFormComponentUpdatingBehavior(onchange) { ... Regards Hans ___ WEB.DE DSL Doppel-Flat ab 19,99 euro;/mtl.! Jetzt auch mit gratis Notebook-Flat! http://produkte.web.de/go/DSL_Doppel_Flatrate/2 - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Jeremy Thomerson http://wickettraining.com *Need a CMS for Wicket? Use Brix! http://brixcms.org* - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Avoid getObject on Model if component not rendered
correct. onconfigure() can be used to control visibility - which includes making an invisible component visible. -igor On Thu, Oct 21, 2010 at 1:00 PM, Bas Gooren b...@iswd.nl wrote: AFAIK onConfigure() is _always_ called, also when a Component is invisible; If I recall correctly this was done to remove the callOnBeforeRenderIfInvisble() method and switching visibility in onBeforeRender(). Bas - Original Message - From: Jeremy Thomerson jer...@wickettraining.com To: users@wicket.apache.org Sent: Thursday, October 21, 2010 9:56 PM Subject: Re: Avoid getObject on Model if component not rendered Or, just set the default value in onConfigure of the dropdownchoice itself, which will not be called if the ddc is not visible. On Thu, Oct 21, 2010 at 2:52 PM, Hans Lesmeister le...@web.de wrote: Create and add the DropDownChoice in onInitialize(). If the component is not rendered then that method will not be called (untested) @Override protected void onInitialize() { super.onInitialize(); final DropDownChoiceCustomUser usersChoice = new DropDownChoiceCustomUser(usersList, customUserModel, usersListModel, new ChoiceRendererCustomUser(username)); usersChoice.setNullValid(false); usersChoice.setModelObject(usersChoice.getChoices().get(0)); usersChoice.add(new AjaxFormComponentUpdatingBehavior(onchange) { ... Regards Hans ___ WEB.DE DSL Doppel-Flat ab 19,99 euro;/mtl.! Jetzt auch mit gratis Notebook-Flat! http://produkte.web.de/go/DSL_Doppel_Flatrate/2 - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Jeremy Thomerson http://wickettraining.com *Need a CMS for Wicket? Use Brix! http://brixcms.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: Avoid getObject on Model if component not rendered
Doh! You're right. onInitialize of the parent component makes sense, or else write a custom model that gets the selected choice from the choices[0], which wouldn't be invoked if the ddc wasn't visible. On Thu, Oct 21, 2010 at 3:00 PM, Igor Vaynberg igor.vaynb...@gmail.comwrote: correct. onconfigure() can be used to control visibility - which includes making an invisible component visible. -igor On Thu, Oct 21, 2010 at 1:00 PM, Bas Gooren b...@iswd.nl wrote: AFAIK onConfigure() is _always_ called, also when a Component is invisible; If I recall correctly this was done to remove the callOnBeforeRenderIfInvisble() method and switching visibility in onBeforeRender(). Bas - Original Message - From: Jeremy Thomerson jer...@wickettraining.com To: users@wicket.apache.org Sent: Thursday, October 21, 2010 9:56 PM Subject: Re: Avoid getObject on Model if component not rendered Or, just set the default value in onConfigure of the dropdownchoice itself, which will not be called if the ddc is not visible. On Thu, Oct 21, 2010 at 2:52 PM, Hans Lesmeister le...@web.de wrote: Create and add the DropDownChoice in onInitialize(). If the component is not rendered then that method will not be called (untested) @Override protected void onInitialize() { super.onInitialize(); final DropDownChoiceCustomUser usersChoice = new DropDownChoiceCustomUser(usersList, customUserModel, usersListModel, new ChoiceRendererCustomUser(username)); usersChoice.setNullValid(false); usersChoice.setModelObject(usersChoice.getChoices().get(0)); usersChoice.add(new AjaxFormComponentUpdatingBehavior(onchange) { ... Regards Hans ___ WEB.DE DSL Doppel-Flat ab 19,99 euro;/mtl.! Jetzt auch mit gratis Notebook-Flat! http://produkte.web.de/go/DSL_Doppel_Flatrate/2 - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Jeremy Thomerson http://wickettraining.com *Need a CMS for Wicket? Use Brix! http://brixcms.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 -- Jeremy Thomerson http://wickettraining.com *Need a CMS for Wicket? Use Brix! http://brixcms.org*