KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > faces > core > component > UIToolbar


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
6 package org.exoplatform.faces.core.component;
7
8 import java.util.ArrayList JavaDoc;
9 import java.util.List JavaDoc ;
10 import java.util.Map JavaDoc;
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 /**
18  * @author Benjamin Mestrallet
19  * benjamin.mestrallet@exoplatform.com
20  */

21 public class UIToolbar extends UIExoCommand {
22   
23   public static final String JavaDoc COMPONENT_FAMILY = "org.exoplatform.faces.core.component.UIToolbar" ;
24   public static final String JavaDoc BUTTON_PARAM = "button" ;
25   
26   private List JavaDoc leftButtons_ = new ArrayList JavaDoc();
27   private List JavaDoc rightButtons_ = new ArrayList JavaDoc();
28
29   public UIToolbar(){
30     this("UIToolbar");
31   }
32   
33   public UIToolbar(String JavaDoc 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 JavaDoc getLeftButtons() { return leftButtons_; }
49
50   public List JavaDoc getRightButtons() { return rightButtons_; }
51   
52   public void decode(FacesContext context) {
53     Map JavaDoc paramMap = context.getExternalContext().getRequestParameterMap() ;
54     String JavaDoc comp = (String JavaDoc) paramMap.get(UICOMPONENT) ;
55     if(getId().equals(comp)) {
56       UIComponent parent = getParent() ;
57       try{
58         String JavaDoc action = (String JavaDoc) paramMap.get(ACTION) ;
59         parent.broadcast(new ExoActionEvent(parent, action, paramMap)) ;
60       } catch (Exception JavaDoc ex) {
61         ex.printStackTrace() ;
62       }
63     }
64   }
65   
66   public void processDecodes(FacesContext context) {
67     decode(context) ;
68   }
69   
70   public String JavaDoc getFamily() { return COMPONENT_FAMILY ; }
71   
72 }
73
Popular Tags