You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by meduolis <me...@gmail.com> on 2010/10/21 21:07:35 UTC

Avoid getObject on Model if component not rendered

Hello, anyone have an idea how to avoid getting model object if component is
not rendered?


ListModel<CustomUser> usersListModel = new ListModel<CustomUser>() {

	private static final long serialVersionUID = -4520573537970008038L;
			
	@Override
	public List<CustomUser> getObject() {
		return customUserDetailsService.loadAllUsers();
	}
			
};
		
final DropDownChoice<CustomUser> usersChoice = new
DropDownChoice<CustomUser>("usersList", customUserModel, usersListModel, new
ChoiceRenderer<CustomUser>("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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Avoid getObject on Model if component not rendered

Posted by meduolis <me...@gmail.com>.
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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Avoid getObject on Model if component not rendered

Posted by Jeremy Thomerson <je...@wickettraining.com>.
On Thu, Oct 21, 2010 at 2:07 PM, meduolis <me...@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

Posted by "hans.lesmeister@lessy.net" <ha...@lessy.net>.


Am 21.10.10 21:07 schrieb "meduolis" unter <me...@gmail.com>:

final DropDownChoice<CustomUser> usersChoice = new
DropDownChoice<CustomUser>("usersList", customUserModel, usersListModel, new
ChoiceRenderer<CustomUser>("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