Hi Per,
Thanks for taking the time to respond. Much appreciated I will work on it
sounds simple should be a good solution. Will ping back from based on how i
go.
Cheers


On Thu, Jun 9, 2011 at 3:24 PM, Per Newgro <per.new...@gmx.ch> wrote:

> Am 09.06.2011 09:01, schrieb Nivedan Nadaraj:
>
>  Hi All,
>>
>> I have a problem to deal with binding selected values into a model within
>> a
>> ListView. I have tried to outline the approach and class definitions out
>> here. I hope I have been clear. Would appreciate your thoughts on the
>> design
>> and approach i have taken so far. I guess am pretty close to it just one
>> hurdle.
>>
>>
>> public class MainVO{
>>     private List<UserModuleRole>  userRoleList;
>> }
>> public class UserModuleRole{
>>         private Role role;
>>         private Module module;
>>         private User user;
>> }
>>
>>
>> *Problem:*
>> 1. I want to list the modules and the roles available for each module in a
>> list view.
>> 2. Select a Role from  each module  for a user
>> 3. Save - Will have the user linked to one or more modules with a role for
>> each.(only one role per module)
>>
>> *Approach*
>>
>> I used a ListView and rendered the list of modules and their respective
>> roles in a drop down. To render this List view these are the steps I took.
>>
>> public class ModuleVO implements Serializable{
>>
>>         private Module module;
>>         private List<Role>  moduleRoles;
>> }
>>
>>
>> 1. I get a Collection/List of ModuleVO via the service. The collection
>> will
>> have a ModuleVO per module with the associated roles as a member.
>> 2. I iterated the list and rendered the Module and render a DropDownChoice
>> 3. End of which I get the following output in the list
>> *
>> Output from List view*:
>>
>> Module       Role
>> --------------------
>> Module-A   Role-1
>>                  Role-2
>>
>> Module-B   Role-3
>>                  Role-4
>>
>> What I have not done and not clear is:
>> 4. At this time I have not bound a Model to the dropdown and just used new
>> Model() for the Model argument of dropDownChoice.
>>
>> I know that the selected values must eventually be in the MainVO's
>> List<UserModuleRole>  userRoleList property.
>>
>> What is not very clear to me at this point is how to bind it ...so that
>> when
>> the user saves the selected values are captured. I am sure this is
>> possible
>> and should be elegant. Your thoughts and time will be of great value.
>>
>> Many thanks
>> Regards
>>
>>  Instanciate the MainVO with a UserModuleRole for every Module and the
> known user. The role
> has only to be loaded if it's already assigned. That is the base.
> If your listview is on a panel / form - give it the MainVO instance.
> Set the MainVO.userRoleList to the ListView by using a
> PropertyModel<List<UserModuleRole>>.
> In ListView.populateItem you get every single UserModuleRole. Render the
> UserModuleRole to the
> ListViewItem.
> The DDC for the roles gets a PropertyModel pointing to the UserModuleRole
> of the ListViewItem.
> The selectable Roles have to be provided by a LoadableDetachableModel
> calling your service.
>
> Hth
> Cheers
> Per
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

Reply via email to