I guess you want to implement multiple selections in a datatable. I experienced 
this issue a while ago and could only work around this problem with the 
following approach. Its requires a bit of work but it works fine ....

The idea is to have an object as a view with the boolean variable representing 
the selection status....

As such i have a Generic View 

  | 
  | public abstract class GenericView<T> {
  | 
  |     private boolean selected=new Boolean(false);    
  | 
  |     private T persistentInstance;           
  | 
  |     public boolean isSelected() {
  |             return selected;
  |     }
  | 
  |     public void setSelected(boolean isSelected) {
  |             this.selected = isSelected;
  |     }
  | 
  |     public T getPersistentInstance() {
  |             return persistentInstance;
  |     }
  | 
  |     public void setPersistentInstance(T persitentInstance) {
  |             this.persistentInstance = persitentInstance;
  |     }
  | }
  | 

I then create a view specific for the object i want to use 

  | public class UserSelectionView extends GenericView<User> {
  | 
  | }
  | 
And a Mapper class which will map the view to the object and vice versa as 
required :

  | public abstract class UserViewMapper {
  |     
  |     public static User MapViewToUser(UserSelectionView view){
  |             return view.getPersistentInstance();
  |     }
  |     
  |     public static UserSelectionView MapUserToView(User user){
  |             
  |             UserSelectionView view = new UserSelectionView();
  |             
  |             view.setPersistentInstance(user);
  |             view.setSelected(false);
  |             
  |             return view;
  |     }
  |     
  | 
  | }
  | 
  | 



In my SFSB, i then use the view as data model and a list of the object 


  | @DataModel
  |     private List<UserSelectionView> userViewListing = new 
LinkedList<UserSelectionView>();
  | 
  | 
  | @Factory("userViewListing")
  |     public void ListUserSelectionViews(){
  |        
  |     List<User> userList = userDAO.selectAll();
  | 
  |    for(User user:userList){
  |     userViewListing.add(UserViewMapper.MapUserToView(user));
  |    }
  | 
  | }
  | 
  | 
  | public void deleteSelectedUser(){
  | 
  | for(UserSelectionView userView:userViewListing){
  |    if(userView.isSelected()){
  |                             
userDAO.remove(UserViewMapper.MapViewToUser(userView));     
  |    }
  | }
  | 
  | }
  | 


Let me know how it goes ...

Cheers,
Jankee Yogesh
Software Developer
http://www.m-itc.net/

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3992836#3992836

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3992836
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to