Beispiel #1
0
 public void execute(Event<UISelectUserForm> event) throws Exception {
   UISelectUserForm uiForm = event.getSource();
   uiForm.setSelectedGroup(uiForm.getSelectedGroup());
   uiForm.setKeyword(null);
   OrganizationService service = CalendarUtils.getOrganizationService();
   if (!CalendarUtils.isEmpty(uiForm.getSelectedGroup())) {
     uiForm.uiIterator_.setPageList(
         service.getUserHandler().findUsersByGroup(uiForm.getSelectedGroup()));
   } else {
     uiForm.uiIterator_.setPageList(service.getUserHandler().getUserPageList(0));
   }
   for (String s : uiForm.pars_) {
     if (uiForm.getUIFormCheckBoxInput(s) != null)
       uiForm.getUIFormCheckBoxInput(s).setChecked(true);
   }
   event.getRequestContext().addUIComponentToUpdateByAjax(uiForm);
 }
Beispiel #2
0
    public void execute(Event<UISelectUserForm> event) throws Exception {
      UISelectUserForm uiForm = event.getSource();
      OrganizationService service = uiForm.getApplicationComponent(OrganizationService.class);
      String keyword = uiForm.getUIStringInput(FIELD_KEYWORD).getValue();
      String filter = uiForm.getUIFormSelectBox(FIELD_FILTER).getValue();
      // uiForm.groupId_ = null ;
      // uiForm.setSelectedGroup(null) ;
      if (CalendarUtils.isEmpty(keyword)) {
        uiForm.init(uiForm.pars_);
      } else {
        keyword = "*" + keyword + "*";
        Query q = new Query();
        if (USER_NAME.equals(filter)) {
          q.setUserName(keyword);
        }
        if (LAST_NAME.equals(filter)) {
          q.setLastName(keyword);
        }
        if (FIRST_NAME.equals(filter)) {
          q.setFirstName(keyword);
        }
        if (EMAIL.equals(filter)) {
          q.setEmail(keyword);
        }
        List results = new CopyOnWriteArrayList();
        results.addAll(service.getUserHandler().findUsers(q).getAll());

        MembershipHandler memberShipHandler = service.getMembershipHandler();
        String groupId = uiForm.getSelectedGroup();
        if (groupId != null && groupId.trim().length() != 0) {
          for (Object user : results) {
            if (memberShipHandler
                    .findMembershipsByUserAndGroup(((User) user).getUserName(), groupId)
                    .size()
                == 0) {
              results.remove(user);
            }
          }
        }
        // ObjectPageList objPageList = new ObjectPageList(results, 10) ;
        LazyPageList<User> pageList =
            new LazyPageList<User>(new ListAccessImpl<User>(User.class, results), 10);
        uiForm.uiIterator_.setPageList(pageList);
      }
      event.getRequestContext().addUIComponentToUpdateByAjax(uiForm);
    }