1 5 package org.exoplatform.portlets.monitor.session.component; 6 7 import java.util.Date ; 8 import java.util.GregorianCalendar ; 9 import org.exoplatform.faces.core.component.UICheckBox; 10 import org.exoplatform.faces.core.component.UIDateInput; 11 import org.exoplatform.faces.core.component.UISimpleForm; 12 import org.exoplatform.faces.core.component.UIStringInput; 13 import org.exoplatform.faces.core.component.model.*; 14 import org.exoplatform.faces.core.event.ExoActionEvent; 15 import org.exoplatform.faces.core.event.ExoActionListener; 16 import org.exoplatform.services.portal.log.Query; 17 23 public class UISearchLogForm extends UISimpleForm { 24 public static final String SEARCH_LOG = "search"; 25 26 private UIStringInput sessionOwner_ ; 27 private UIStringInput remoteUser_ ; 28 private UIStringInput ipAddress_ ; 29 private UIStringInput clientType_ ; 30 private UICheckBox error_ ; 31 private UIDateInput fromDate_ ; 32 private UIDateInput toDate_ ; 33 34 public UISearchLogForm() { 35 super("searchForm", "post", null) ; 36 setId("UISearchLogForm"); 37 setClazz("UIAdvancedSearch"); 38 sessionOwner_ = new UIStringInput("sessionOwner", "") ; 39 remoteUser_ = new UIStringInput("remoteUser", "") ; 40 ipAddress_ = new UIStringInput("ipAddress", "") ; 41 clientType_ = new UIStringInput("clientType", "") ; 42 error_ = new UICheckBox("error", "true"); 43 fromDate_ = new UIDateInput("fromDate", new GregorianCalendar (2004, 0, 1).getTime()) ; 44 toDate_ = new UIDateInput("toDate", new Date ()) ; 45 add(new Row(). 46 add(new LabelCell("#{UISearchLogForm.label.session-owner}")). 47 add(new ComponentCell(this, sessionOwner_))) ; 48 add(new Row(). 49 add(new LabelCell("#{UISearchLogForm.label.remote-user}")). 50 add(new ComponentCell(this, remoteUser_))) ; 51 add(new Row(). 52 add(new LabelCell("#{UISearchLogForm.label.ip-address}")). 53 add(new ComponentCell(this, ipAddress_))) ; 54 add(new Row(). 55 add(new LabelCell("#{UISearchLogForm.label.client-type}")). 56 add(new ComponentCell(this, clientType_))) ; 57 add(new Row(). 58 add(new LabelCell("#{UISearchLogForm.label.access-time}")). 59 add(new ListComponentCell(). 60 add(this, fromDate_). 61 add("#{UISearchLogForm.label.to}"). 62 add(this, toDate_))) ; 63 add(new Row(). 64 add(new LabelCell("#{UISearchLogForm.label.error}")). 65 add(new ComponentCell(this, error_))) ; 66 add(new Row(). 67 add(new ListComponentCell(). 68 add(new FormButton("#{UISearchLogForm.button.search}", SEARCH_LOG)). 69 add(new FormButton("#{UISearchLogForm.button.cancel}", CANCEL_ACTION)). 70 addColspan("2").addAlign("center"))) ; 71 72 addActionListener(SearchUserActionListener.class, SEARCH_LOG) ; 73 addActionListener(CancelActionListener.class, CANCEL_ACTION) ; 74 } 75 76 77 static public class SearchUserActionListener extends ExoActionListener { 78 public void execute(ExoActionEvent event) throws Exception { 79 UISearchLogForm uiForm = (UISearchLogForm) event.getComponent() ; 80 UIListSessionLog uiList = 81 (UIListSessionLog) uiForm.getSibling(UIListSessionLog.class); 82 Query q = new Query() ; 83 q.setSessionOwner(uiForm.sessionOwner_.getValue()) ; 84 q.setRemoteUser(uiForm.remoteUser_.getValue()) ; 85 q.setIPAddress(uiForm.ipAddress_.getValue()) ; 86 q.setClientType(uiForm.clientType_.getValue()) ; 87 q.setFromDate(uiForm.fromDate_.getValue()) ; 88 q.setToDate(uiForm.toDate_.getValue()) ; 89 if(uiForm.error_.getSelect()) q.setError(1) ; 90 uiList.update(q) ; 91 uiForm.setRenderedSibling(UIListSessionLog.class) ; 92 } 93 } 94 95 static public class CancelActionListener extends ExoActionListener { 96 public void execute(ExoActionEvent event) throws Exception { 97 UISearchLogForm uiForm = (UISearchLogForm) event.getComponent() ; 98 uiForm.setRenderedSibling(UIListSessionLog.class) ; 99 } 100 } 101 } | Popular Tags |