Hi All, I have used the Palette successfully in another scenario where it was pretty straightforward, in that the bean/pojo has a selectedItmes and availableItems property on the bean. That was nice and clean and would like to do the same in the scenario below. If someone has any ideas do let me know.
Will describe the POJOS and what I want to achive.. The Pojos: public class RoleVO implements Serializable { private String roleName; // .. Getters and setters } public class ModuleVO implements Serializable{ private String moduleName; private List<RoleVO> selectedRoles; // .. Getters and setters } public class ModuleRoleVO implements Serializable{ private List<ModuleVO> selectedModules; //Represents the user associated modules and their roles private List<ModuleVO> availableModules; //The list of choices } Lets say the ModuleRoleVO.availableModules list contains the following items/data: Module-A and contains Role-A and Role-B Module-B and contains Role-A2 and Role-A3 and Assuming that ModuleRoleVO.selectedModules list contains only one item Module-A and it contains Role-A and Role-B I currently build a Wiquery based Accordion control and each Panel of the accordion uses the ModuleRoleVO.availableModules to render the header/section name of the Accordion Panel. So the Accordion would be rendered like this. Module-A --> Section 1 of accordion Module-B--> Section 2 of accordion Now within each of the accordion Panel I want to insert the Palette control that should display the available roles and selected roles for the module * linked* with the section. like so *Module-A* Available Roles Selected Roles Role-A Role-B *Module-B* Available Roles Selected Roles Role-A2 Role-A3 I would like to achieve the above and maintain the selected choices in the model across submits. What I have achieved so far and my doubt... I got to the point where I render the accordion with the respective module names and add the palette within it. I provide the list of available roles for the module as a PropertyModel into the Palette. I do the same, as in provide the selected roles by comparing the module name in the list of selectedModules list and if found get the list of roles and build a PropertyModel and pass it to the palette. However all this happens manually at initialization of the Palette. Once I submit the values the selected items of each Paletted is infered by me manually and then I pass it to be persisted. After it persits, the Palette loses the selected choices. The reason being its not bound properly with the Model. If it can infer the values from the bean it would be right. But I am missing something here or maybe I gott to apporach it differently. A Snippet of the code that builds the listview for the Accordion and initialization of the Palette. ListView sectionListView = new ListView(Constants.ACCORDION_SECTION, containerForm.getModelObject().getAvailableModules()){ /** * */ private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem listItem) { ModuleVO availableModuleVO = ((ModuleVO)listItem.getDefaultModelObject()); Label sectionName = new Label(Constants.ACCORDION_SECTION_NAME_LBL, availableModuleVO.getModule()); listItem.setRenderBodyOnly(true);//Excludes excess tags on the markup listItem.add(sectionName); String displayModule; ModuleVO selectedModuleVO = new ModuleVO(); //Match the available Module name with the user associated module list for(ModuleVO userModule :membershipModules){ displayModule = UIHelper.getDisplayModuleName(userModule.getModule()); if(displayModule.equals(availableModuleVO.getModule())){ selectedModuleVO = userModule; break; } } Palette rolePalette = initialiseRolePalette(containerForm,selectedModuleVO,availableModuleVO); listItem.add(rolePalette); } }; moduleAccordion.add(sectionListView); appRoleForm.add(moduleAccordion);//Add the accordion to the form add(appRoleForm); } private Palette initialiseRolePalette(ContainerForm containerForm, ModuleVO selectedModuleVO, ModuleVO availableModuleVO){ CompoundPropertyModel<ModuleRoleVO> moduleRoleCPM = (CompoundPropertyModel<ModuleRoleVO>)containerForm.getModel(); IChoiceRenderer<String> renderer = new ChoiceRenderer<String>("role", "role"); PropertyModel<List<RoleVO>> availableRoleChoicesPM = new PropertyModel<List<RoleVO>>(availableModuleVO,"role"); PropertyModel<List<RoleVO>> selectedRolesPM = new PropertyModel<List<RoleVO>>(selectedModuleVO,"role"); return new Palette("role", selectedRolesPM, availableRoleChoicesPM, renderer, 5, false); } If someone around with an experience with a similar use case or identical one please give me a yell. Thanks for the time. Regards Niv