You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by jo...@bt.com on 2012/01/24 10:38:46 UTC
T5.2.5 Palette Component used with OptionGroupModel - deselect issue
Hi,
I'm using a Palette component with OptionGroupModels to show a list as below:
Region 1
Country 1
Country 2
Country 3
Region 2
Country 4
Country 5
Country 6
When I select individual countries from region 1, I can deselect them and they will return to the correct OptionGroupModel (ie region 1). If I select all countries from region 1, when I deselect them they will be put into Region 2. When selecting all countries from region 2, when I deselect them, they return to the correct region. If I swap the order of the option groups so that region 2 comes first, then the same behaviour is observed, with region 1 working correctly and all region 2 countries not being returned to the correct region when deselected.
This is my hacked together attempt to get it working, as I haven't been able to find any examples of using the palette with OptionGroupModels:
void onPrepare() {
availableCountries = bidApplicationManager.findallUserAccessCountries();
countryModel = new SelectModelImpl(createOptionGroups(this.availableCountries),null);
}
private List<OptionGroupModel> createOptionGroups(List<Country> availableCountries) {
List<OptionGroupModel> optGroupList = new ArrayList<OptionGroupModel>();
List<OptionModel> optList = new ArrayList<OptionModel>();
List<OptionModel> nonEEAOptList = new ArrayList<OptionModel>();
for(Country country: availableCountries2){
if (country.getRegion().equals("Europe (EEA)")){
OptionModelImpl opt = new OptionModelImpl(country.getCountry(),country);
optList.add(opt);
}
else if (!(country.getRegion().equals("Europe (EEA)"))){
OptionModelImpl opt = new OptionModelImpl(country.getCountry(),country);
nonEEAOptList.add(opt);
}
}
OptionGroupModel groupModel = new OptionGroupModelImpl("Europe (EEA)",false,optList);
OptionGroupModel NonEEAGroupModel = new OptionGroupModelImpl("Non EEA",false,nonEEAOptList);
optGroupList.add(groupModel);
optGroupList.add(NonEEAGroupModel);
return optGroupList;
}
The Palette API documentation states that "Option groups within the SelectModel<http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/SelectModel.html> will be rendered, but are not supported by many browsers, and are not fully handled on the client side. "
I'm not sure if there is something that I am doing wrong, or the behaviour I'm seeing is due to it being "not fully handled on the client side". Has anyone got a working palette using option groups? Any pointers/comments welcome.
Thanks & Regards
Jonathan