You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Nivedan Nadaraj <sh...@gmail.com> on 2011/06/09 09:01:06 UTC

Binding selected values from a ListView into a Mode

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

Re: Binding selected values from a ListView into a Mode

Posted by Per Newgro <pe...@gmx.ch>.
Am 09.06.2011 10:07, schrieb Madan Mohan:
> Hi,
>          I am using<wicket:enclosure>to hide some rows in a table.
>
> Take for ex.,
>           <tr><td>  Phone:<span wicket:id="phoneNumber"/></td></tr>
>           <wicket:enclosure>
>                      <tr><td>  Fax:<span wicket:id="faxNumber"td></tr>
>           </wicket:enclosure>
>
> Initially faxNumber is *not visible*. So the faxNumber row is not rendered.
> Later based on some user action, i want to make faxNumber to *visible*.
>
> How to do this?
>
> regards,
> *Madan*
> *www.educator.eu*
>
1) Please don't capture threads. Open another one.
2) You can overwrite onConfigure in every component and set visibility 
by calling Component.setVisible.
So you need to call
spanWithWicketIdfaxNumber.setVisible(true);
if your conditions are met.

Hth
Per

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Binding selected values from a ListView into a Mode

Posted by Madan Mohan <mm...@educator.eu>.
Hi,
        I am using <wicket:enclosure>to hide some rows in a table.

Take for ex.,
         <tr><td> Phone: <span wicket:id="phoneNumber"/></td></tr>
         <wicket:enclosure>
                    <tr><td> Fax: <span wicket:id="faxNumber"td></tr>
         </wicket:enclosure>

Initially faxNumber is *not visible*. So the faxNumber row is not rendered.
Later based on some user action, i want to make faxNumber to *visible*.

How to do this?

regards,
*Madan*
*www.educator.eu*

Re: Binding selected values from a ListView into a Mode

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

Re: Binding selected values from a ListView into a Mode

Posted by Nivedan Nadaraj <sh...@gmail.com>.
Hi

Yep I got it going. Prepopulating and the 'the base/fundamental' was a good
start that kinda helped in looking at other parts of the problem. Thanks for
the time

Cheers

On Thu, Jun 9, 2011 at 3:24 PM, Per Newgro <pe...@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-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Binding selected values from a ListView into a Mode

Posted by Per Newgro <pe...@gmx.ch>.
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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org