1 5 package org.exoplatform.portal.faces.component; 6 7 import java.util.ArrayList ; 8 import java.util.List ; 9 import org.exoplatform.faces.core.component.UISelectBox; 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 16 22 public class UISearchForm extends UISimpleForm { 23 private static List PERMISSIONS ; 24 static { 25 PERMISSIONS = new ArrayList (10) ; 26 PERMISSIONS.add(new SelectItem("All", "")) ; 27 PERMISSIONS.add(new SelectItem("owner", "owner")) ; 28 PERMISSIONS.add(new SelectItem("any", "any")) ; 29 } 30 31 private UIStringInput ownerInput_ ; 32 private UISelectBox viewPermissionInput_ ; 33 private UISelectBox editPermissionInput_ ; 34 35 public UISearchForm() { 36 super("searchForm", "post", null) ; 37 setId("UISearchForm"); 38 ownerInput_ = new UIStringInput("owner", "") ; 39 viewPermissionInput_ = new UISelectBox("viewPermission","" , PERMISSIONS) ; 40 editPermissionInput_ = new UISelectBox("editPermission","" , PERMISSIONS) ; 41 add(new Row(). 42 add(new LabelCell("#{UISearchForm.label.owner}")). 43 add(new ComponentCell(this, ownerInput_))) ; 44 add(new Row(). 45 add(new LabelCell("#{UISearchForm.label.view-permission}")). 46 add(new ComponentCell(this, viewPermissionInput_))) ; 47 add(new Row(). 48 add(new LabelCell("#{UISearchForm.label.edit-permission}")). 49 add(new ComponentCell(this, editPermissionInput_))) ; 50 add(new Row(). 51 add(new ListComponentCell(). 52 add(new FormButton("#{UISearchForm.button.search}", "searchPages")). 53 addColspan("2").addAlign("center"))) ; 54 55 addActionListener(SearchPagesActionListener.class, "searchPages") ; 56 } 57 58 public String getOwner() { return ownerInput_.getValue() ;} 59 public void setOwner(String owner) { ownerInput_.setValue(owner) ;} 60 61 public String getViewPermission() { return viewPermissionInput_.getValue() ;} 62 public void setViewPermission(String s) { viewPermissionInput_.setValue(s) ;} 63 64 public String getEditPermission() { return editPermissionInput_.getValue() ;} 65 public void setEditPermission(String s) { editPermissionInput_.setValue(s) ;} 66 67 static public class SearchPagesActionListener extends ExoActionListener { 68 public void execute(ExoActionEvent event) throws Exception { 69 UISearchForm uiForm = (UISearchForm) event.getSource() ; 70 UIPageList uiList = (UIPageList) uiForm.getParent(); 71 uiList.queryDescriptions(uiForm.ownerInput_.getValue(), 72 uiForm.viewPermissionInput_.getValue(), 73 uiForm.editPermissionInput_.getValue()) ; 74 } 75 } 76 77 } | Popular Tags |