You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Robert Gründler <ro...@dubture.com> on 2010/03/28 12:43:06 UTC

Wizard using ListView and RadioGroup

Hi all,

i'm working on a Wizard that displays a list of Addresses in one step, where
an address can be selected using a radiobutton.

The relevant code of the addresslist-wizardstep looks like this:

addressList = new ArrayList<UserAddress>(user.getAddresses());
final RadioGroup group = new RadioGroup("group", new CompoundPropertyModel(addressList));
add(group);

ListView<UserAddress> userAddresses = new ListView<UserAddress>("addresses", addressList) {
	@Override
	protected void populateItem(ListItem<UserAddress> item) {
		item.setDefaultModel(new CompoundPropertyModel<UserAddress>(item.getModelObject()));
		item.add(new Radio("is_default"));					
		item.add(new Label("address.street"));
		item.add(new Label("address.zip"));
		item.add(new Label("address.city"));
		item.add(new Label("address.country"));
	}
};

group.add(userAddresses);
group.setRequired(true);

My Problem is that i need to select an address by default based on the is_default field in the UserAddress jointable, but only
when the wizardStep is displayed for the first time. If the user changes the selected address, it should not jump back
to the is_default value when switching back and forth between wizard-steps.

I've already tried the solution described in the wiki for setting default values to radiogroups (http://cwiki.apache.org/WICKET/using-radiogroups.html),
but this resets the selected radiobutton when switching wizard pages to the default value, so the wizard doesn't "remember"  if a default option
has been changed by the user.

I'd appreciate any hints on how to solve this one.


thanks!


-robert





Re: Wizard using ListView and RadioGroup

Posted by Martijn Dashorst <ma...@gmail.com>.
userAddresses.setReuseItems(true)

Martijn

2010/3/28 Robert Gründler <ro...@dubture.com>:
> Hi all,
>
> i'm working on a Wizard that displays a list of Addresses in one step, where
> an address can be selected using a radiobutton.
>
> The relevant code of the addresslist-wizardstep looks like this:
>
> addressList = new ArrayList<UserAddress>(user.getAddresses());
> final RadioGroup group = new RadioGroup("group", new CompoundPropertyModel(addressList));
> add(group);
>
> ListView<UserAddress> userAddresses = new ListView<UserAddress>("addresses", addressList) {
>        @Override
>        protected void populateItem(ListItem<UserAddress> item) {
>                item.setDefaultModel(new CompoundPropertyModel<UserAddress>(item.getModelObject()));
>                item.add(new Radio("is_default"));
>                item.add(new Label("address.street"));
>                item.add(new Label("address.zip"));
>                item.add(new Label("address.city"));
>                item.add(new Label("address.country"));
>        }
> };
>
> group.add(userAddresses);
> group.setRequired(true);
>
> My Problem is that i need to select an address by default based on the is_default field in the UserAddress jointable, but only
> when the wizardStep is displayed for the first time. If the user changes the selected address, it should not jump back
> to the is_default value when switching back and forth between wizard-steps.
>
> I've already tried the solution described in the wiki for setting default values to radiogroups (http://cwiki.apache.org/WICKET/using-radiogroups.html),
> but this resets the selected radiobutton when switching wizard pages to the default value, so the wizard doesn't "remember"  if a default option
> has been changed by the user.
>
> I'd appreciate any hints on how to solve this one.
>
>
> thanks!
>
>
> -robert
>
>
>
>
>



-- 
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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org