1 5 package org.exoplatform.portlets.user.component; 6 7 import java.util.ArrayList ; 8 import java.util.List ; 9 import org.exoplatform.faces.core.component.model.SelectItem; 10 import org.exoplatform.faces.search.component.UISearchBar; 11 import org.exoplatform.faces.search.component.UISearcher; 12 import org.exoplatform.services.organization.Query; 13 18 public class UIUserManager extends UISearcher { 19 20 public UIUserManager() throws Exception { 21 setId("UISearcher") ; 22 setRendererType("ChildrenRenderer") ; 23 List options = new ArrayList () ; 24 options.add(new SelectItem("#{UISearchBar.label.search-all}", "")); 25 options.add(new SelectItem("#{UISearchBar.label.username}", "username")); 26 options.add(new SelectItem("#{UISearchBar.label.first-name}","firstname")); 27 options.add(new SelectItem("#{UISearchBar.label.last-name}", "lastname")); 28 options.add(new SelectItem("#{UISearchBar.label.email}", "email")); 29 UISearchBar uiBar = new UISearchBar(); 30 uiBar.setSearchOptions(options) ; 31 getChildren().add(uiBar) ; 32 addChild(UIListUser.class) ; 33 addChild(UISearchUserForm.class).setRendered(false) ; 34 addChild(UIUserProfileSummary.class).setRendered(false) ; 35 addChild(UIUserInfo.class).setRendered(false) ; 36 } 37 38 public void showAdvancedSearch() throws Exception { 39 setRenderedComponent(UISearchUserForm.class) ; 40 } 41 42 public void quickSearch(String term, List fields) throws Exception { 43 Query query = new Query() ; 44 if(term != null && term.length() > 0 && fields.size() == 1) { 45 String field = (String ) fields.get(0) ; 46 if("username".equals(field)) query.setUserName(term) ; 47 else if("lastname".equals(field))query.setFirstName(term) ; 48 else if("firstname".equals(field))query.setLastName(term) ; 49 else if("email".equals(field))query.setEmail(term) ; 50 } 51 UIListUser uiListUser = (UIListUser) getChildComponentOfType(UIListUser.class) ; 52 uiListUser.search(query) ; 53 setRenderedComponent(UIListUser.class) ; 54 } 55 } | Popular Tags |