1 5 package org.exoplatform.portlets.portal.component; 6 7 import java.util.ArrayList ; 8 import java.util.List ; 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 28 public class UISearchForm extends UISimpleForm { 29 private static List PERMISSIONS ; 30 static { 31 PERMISSIONS = new ArrayList (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 { 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 |