KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portlets > user > component > UIUserManager


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.portlets.user.component;
6
7 import java.util.ArrayList JavaDoc;
8 import java.util.List JavaDoc;
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 /**
14  * @author Tuan Nguyen (tuan08@users.sourceforge.net)
15  * @since Aug 27, 2004
16  * @version $Id: UIContentSearcher.java,v 1.1 2004/10/25 03:48:11 tuan08 Exp $
17  */

18 public class UIUserManager extends UISearcher {
19
20   public UIUserManager() throws Exception JavaDoc {
21     setId("UISearcher") ;
22     setRendererType("ChildrenRenderer") ;
23     List JavaDoc options = new ArrayList JavaDoc() ;
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 JavaDoc {
39     setRenderedComponent(UISearchUserForm.class) ;
40   }
41   
42   public void quickSearch(String JavaDoc term, List JavaDoc fields) throws Exception JavaDoc {
43     Query query = new Query() ;
44     if(term != null && term.length() > 0 && fields.size() == 1) {
45       String JavaDoc field = (String JavaDoc) 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