KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portlets > portal > component > UISearchForm


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.portal.component;
6
7 import java.util.ArrayList JavaDoc;
8 import java.util.List JavaDoc;
9
10 import org.exoplatform.faces.core.component.UISelectBox;
11 import org.exoplatform.faces.core.component.UISimpleForm;
12 import org.exoplatform.faces.core.component.UIStringInput;
13 import org.exoplatform.faces.core.component.model.ComponentCell;
14 import org.exoplatform.faces.core.component.model.FormButton;
15 import org.exoplatform.faces.core.component.model.LabelCell;
16 import org.exoplatform.faces.core.component.model.ListComponentCell;
17 import org.exoplatform.faces.core.component.model.Row;
18 import org.exoplatform.faces.core.component.model.SelectItem;
19 import org.exoplatform.faces.core.event.ExoActionEvent;
20 import org.exoplatform.faces.core.event.ExoActionListener;
21 import org.exoplatform.services.portal.Query;
22 /**
23  * Sat, Jan 03, 2004 @ 11:16
24  * @author: Tuan Nguyen
25  * @email: tuan08@users.sourceforge.net
26  * @version: $Id: UISearchForm.java,v 1.4 2004/09/29 17:44:51 benjmestrallet Exp $
27  */

28 public class UISearchForm extends UISimpleForm {
29   private static List JavaDoc PERMISSIONS ;
30   static {
31     PERMISSIONS = new ArrayList JavaDoc(10) ;
32     PERMISSIONS.add(new SelectItem("All", "")) ;
33     PERMISSIONS.add(new SelectItem("owner", "owner")) ;
34     PERMISSIONS.add(new SelectItem("any", "any")) ;
35   }
36   
37   private UIStringInput ownerInput_ ;
38   private UISelectBox viewPermissionInput_ ;
39   private UISelectBox editPermissionInput_ ;
40
41   public UISearchForm() {
42     super("searchForm", "post", null) ;
43     setId("UISearchForm");
44     ownerInput_ = new UIStringInput("owner", "") ;
45     viewPermissionInput_ = new UISelectBox("viewPermission","" , PERMISSIONS) ;
46     editPermissionInput_ = new UISelectBox("editPermission","" , PERMISSIONS) ;
47     add(new Row().
48         add(new LabelCell("#{UISearchForm.label.owner}")).
49         add(new ComponentCell(this, ownerInput_))) ;
50     add(new Row().
51         add(new LabelCell("#{UISearchForm.label.view-permission}")).
52         add(new ComponentCell(this, viewPermissionInput_))) ;
53     add(new Row().
54         add(new LabelCell("#{UISearchForm.label.edit-permission}")).
55         add(new ComponentCell(this, editPermissionInput_))) ;
56     add(new Row().
57         add(new ListComponentCell().
58             add(new FormButton("#{UISearchForm.button.search}", "search")).
59             addColspan("2").addAlign("center"))) ;
60     
61     addActionListener(SearchPagesActionListener.class, "search") ;
62   }
63   
64   static public class SearchPagesActionListener extends ExoActionListener {
65         public void execute(ExoActionEvent event) throws Exception JavaDoc {
66           UISearchForm uiForm = (UISearchForm) event.getSource() ;
67       UIAvailablePortal uiTarget =
68         (UIAvailablePortal) uiForm.getParent() ;
69       Query q = new Query(uiForm.ownerInput_.getValue(),
70                           uiForm.viewPermissionInput_.getValue(),
71                           uiForm.editPermissionInput_.getValue());
72       uiTarget.refresh(q) ;
73         }
74   }
75 }
Popular Tags