1 5 6 package org.exoplatform.faces.core.component; 7 8 import java.util.ArrayList ; 9 import java.util.List ; 10 import java.util.Map ; 11 12 import javax.faces.component.UIComponent; 13 import javax.faces.context.FacesContext; 14 import org.exoplatform.faces.core.component.model.Button; 15 import org.exoplatform.faces.core.event.ExoActionEvent; 16 17 21 public class UIToolbar extends UIExoCommand { 22 23 public static final String COMPONENT_FAMILY = "org.exoplatform.faces.core.component.UIToolbar" ; 24 public static final String BUTTON_PARAM = "button" ; 25 26 private List leftButtons_ = new ArrayList (); 27 private List rightButtons_ = new ArrayList (); 28 29 public UIToolbar(){ 30 this("UIToolbar"); 31 } 32 33 public UIToolbar(String id){ 34 setId(id); 35 setRendererType("ToolbarRenderer") ; 36 setRendered(true); 37 } 38 39 public void addLeftButton(Button button){ 40 leftButtons_.add(button); 41 } 42 43 public void addRightButton(Button button){ 44 rightButtons_.add(button); 45 } 46 47 48 public List getLeftButtons() { return leftButtons_; } 49 50 public List getRightButtons() { return rightButtons_; } 51 52 public void decode(FacesContext context) { 53 Map paramMap = context.getExternalContext().getRequestParameterMap() ; 54 String comp = (String ) paramMap.get(UICOMPONENT) ; 55 if(getId().equals(comp)) { 56 UIComponent parent = getParent() ; 57 try{ 58 String action = (String ) paramMap.get(ACTION) ; 59 parent.broadcast(new ExoActionEvent(parent, action, paramMap)) ; 60 } catch (Exception ex) { 61 ex.printStackTrace() ; 62 } 63 } 64 } 65 66 public void processDecodes(FacesContext context) { 67 decode(context) ; 68 } 69 70 public String getFamily() { return COMPONENT_FAMILY ; } 71 72 } 73 | Popular Tags |