KickJava   Java API By Example, From Geeks To Geeks.

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


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.faces.core.component;
6
7 import java.util.ArrayList JavaDoc;
8 import java.util.List JavaDoc;
9
10 import javax.faces.component.UIComponent;
11 import javax.faces.context.FacesContext;
12 import org.exoplatform.faces.core.event.UIComponentObserver;
13
14 /**
15  * Jun 2, 2004
16  * @author: Tuan Nguyen
17  * @email: tuan08@users.sourceforge.net
18  * @version: $ID$
19  **/

20 public class UICommandNode extends UIExoCommand implements Node {
21     private String JavaDoc name_ ;
22     private String JavaDoc icon_ ;
23     private String JavaDoc description_ ;
24   private List JavaDoc observers_ ;
25     
26     public String JavaDoc getName() { return name_ ; }
27     public void setName(String JavaDoc s) { name_ = s ;}
28     
29     public String JavaDoc getIcon() { return icon_ ; }
30     public void setIcon(String JavaDoc s) { icon_ = s ; }
31     
32     public String JavaDoc getDescription() { return description_ ;}
33     public void setDescription(String JavaDoc s) { description_ = s ; }
34
35     public void addObserver(UIComponentObserver observer) {
36       if(observers_ == null) observers_ = new ArrayList JavaDoc(3) ;
37       observers_.add(observer) ;
38     }
39     
40     public void broadcastOnChange() throws Exception JavaDoc {
41       if(observers_ != null) {
42         for(int i = 0; i < observers_.size(); i++) {
43           UIComponentObserver observer = (UIComponentObserver) observers_.get(i) ;
44           observer.onChange(this) ;
45         }
46       }
47     }
48     
49     public void processDecodes(FacesContext context) {
50     List JavaDoc children = getChildren() ;
51     decode(context) ;
52     if (context.getRenderResponse()) return ;
53     for(int i = 0 ; i < children.size(); i++) {
54       UIComponent child = (UIComponent) children.get(i);
55       if (child.isRendered()) {
56         child.processDecodes(context) ;
57         if (context.getRenderResponse()) return ;
58       }
59     }
60   }
61 }
Popular Tags