Time for action – using the basic PickList component
Let us see how we can create a PickList component to grant and revoke privileges to and from users, by performing the following steps:
- Initialize
DualListModel
in the managed bean:public class PickListController { private DualListModel<String> privileges; public PickListController() { List<String> privilegesSource = new ArrayList<String>(); List<String> privilegesTarget = new ArrayList<String>(); privilegesSource.add("Create User"); privilegesSource.add("Delete User"); privilegesSource.add("Disable User"); privilegesSource.add("Remove Buzz Post"); privileges = new DualListModel<String>(privilegesSource, privilegesTarget); } //setter and getter for privileges }
- Use the
<p:pickList>
component to create a PickList component:<p:pickList id="pickList" ...