1 5 package org.exoplatform.portlets.user.component; 6 7 import java.util.Date ; 8 import java.util.GregorianCalendar ; 9 import org.exoplatform.faces.core.component.UIDateInput; 10 import org.exoplatform.faces.core.component.UISimpleForm; 11 import org.exoplatform.faces.core.component.UIStringInput; 12 import org.exoplatform.faces.core.component.model.*; 13 import org.exoplatform.faces.core.event.ExoActionEvent; 14 import org.exoplatform.faces.core.event.ExoActionListener; 15 import org.exoplatform.services.organization.Query; 16 22 public class UISearchUserForm extends UISimpleForm { 23 24 public static final String SEARCH_USER = "searchUser"; 25 26 private UIStringInput username_ ; 27 private UIStringInput fname_ ; 28 private UIStringInput lname_ ; 29 private UIStringInput email_ ; 30 private UIDateInput fromDate_ ; 31 private UIDateInput toDate_ ; 32 33 public UISearchUserForm() { 34 super("searchForm", "post", null) ; 35 setId("UISearchUserForm"); 36 setClazz("UIAdvancedSearch"); 37 username_ = new UIStringInput("userName", "") ; 38 fname_ = new UIStringInput("fname", "") ; 39 lname_ = new UIStringInput("lname", "") ; 40 email_ = new UIStringInput("email", "") ; 41 fromDate_ = new UIDateInput("fromDate", new GregorianCalendar (2004, 0, 1).getTime()) ; 42 toDate_ = new UIDateInput("toDate", new Date ()) ; 43 add(new Row(). 44 add(new LabelCell("#{UISearchUserForm.label.username}")). 45 add(new ComponentCell(this, username_))) ; 46 add(new Row(). 47 add(new LabelCell("#{UISearchUserForm.label.first-name}")). 48 add(new ComponentCell(this, fname_))) ; 49 add(new Row(). 50 add(new LabelCell("#{UISearchUserForm.label.last-name}")). 51 add(new ComponentCell(this, lname_))) ; 52 add(new Row(). 53 add(new LabelCell("#{UISearchUserForm.label.email}")). 54 add(new ComponentCell(this, email_))) ; 55 add(new Row(). 56 add(new LabelCell("#{UISearchUserForm.label.login-time}")). 57 add(new ListComponentCell(). 58 add(this, fromDate_). 59 add("#{UISearchUserForm.label.to}"). 60 add(this, toDate_))) ; 61 add(new Row(). 62 add(new ListComponentCell(). 63 add(new FormButton("#{UISearchUserForm.button.search}", SEARCH_USER)). 64 add(new FormButton("#{UISearchUserForm.button.cancel}", CANCEL_ACTION)). 65 addColspan("2").addAlign("center"))) ; 66 67 addActionListener(SearchUserActionListener.class, SEARCH_USER) ; 68 addActionListener(CancelActionListener.class, CANCEL_ACTION ); 69 } 70 71 static public class SearchUserActionListener extends ExoActionListener { 72 public void execute(ExoActionEvent event) throws Exception { 73 UISearchUserForm uiForm = (UISearchUserForm) event.getComponent() ; 74 UIListUser uiListUser = (UIListUser) uiForm.getSibling(UIListUser.class) ; 75 Query query = new Query() ; 76 query.setUserName(uiForm.username_.getValue()) ; 77 query.setFirstName(uiForm.fname_.getValue()) ; 78 query.setLastName(uiForm.lname_.getValue()) ; 79 query.setEmail(uiForm.email_.getValue()) ; 80 query.setFromLoginDate(uiForm.fromDate_.getValue()) ; 81 query.setToLoginDate(uiForm.toDate_.getValue()) ; 82 uiListUser.search(query) ; 83 uiForm.setRenderedSibling(UIListUser.class) ; 84 } 85 } 86 87 static public class CancelActionListener extends ExoActionListener { 88 public void execute(ExoActionEvent event) throws Exception { 89 UISearchUserForm uiForm = (UISearchUserForm) event.getComponent() ; 90 uiForm.username_.setValue("") ; 91 uiForm.fname_.setValue("") ; 92 uiForm.lname_.setValue("") ; 93 uiForm.email_.setValue("") ; 94 uiForm.setRenderedSibling(UIListUser.class) ; 96 } 97 } 98 } | Popular Tags |