KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portlets > monitor > session > component > UISearchLogForm


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.monitor.session.component;
6
7 import java.util.Date JavaDoc;
8 import java.util.GregorianCalendar JavaDoc;
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 /**
18  * Sat, Jan 03, 2004 @ 11:16
19  * @author: Tuan Nguyen
20  * @email: tuan08@users.sourceforge.net
21  * @version: $Id: UISearchUserForm.java,v 1.6 2004/10/22 14:23:30 tuan08 Exp $
22  */

23 public class UISearchLogForm extends UISimpleForm {
24   public static final String JavaDoc 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 JavaDoc(2004, 0, 1).getTime()) ;
44     toDate_ = new UIDateInput("toDate", new Date JavaDoc()) ;
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 JavaDoc {
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 JavaDoc {
97       UISearchLogForm uiForm = (UISearchLogForm) event.getComponent() ;
98       uiForm.setRenderedSibling(UIListSessionLog.class) ;
99     }
100   }
101 }
Popular Tags