KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portlet > faces > component > UIExoViewRoot


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.portlet.faces.component;
6
7 import java.util.* ;
8 import java.io.IOException JavaDoc;
9 import javax.faces.component.UIViewRoot ;
10 import javax.faces.context.FacesContext;
11 import javax.faces.component.UIComponent;
12 import org.exoplatform.faces.UIComponentFactory;
13 import org.exoplatform.faces.core.component.UIExoComponent;
14 /**
15  * @author Tuan Nguyen (tuan08@users.sourceforge.net)
16  * @since Nov 9, 2003 2:27:49 PM
17  *
18  */

19 public class UIExoViewRoot extends UIViewRoot {
20   private boolean isComponentView_ ;
21   
22   public UIExoViewRoot(String JavaDoc viewId) {
23     super() ;
24     isComponentView_ = false ;
25     setViewId(viewId) ;
26     if (viewId.endsWith(".class")) {
27       String JavaDoc clazz = viewId.substring(0, viewId.length() - 6) ;
28       getChildren().add(createComponent(clazz)) ;
29       isComponentView_ = true ;
30     }
31   }
32
33   public boolean isComponentView() { return isComponentView_ ; }
34   
35   static public UIComponent createComponent(String JavaDoc clazz) {
36     try {
37         UIComponentFactory factory = new UIComponentFactory() ;
38       UIComponent component = (UIComponent) factory.createUIComponent(clazz);
39       return component ;
40     } catch (Throwable JavaDoc t) {
41       t.printStackTrace() ;
42     }
43     return null ;
44   }
45
46   public void renderChildren( FacesContext context) throws IOException JavaDoc {
47     Iterator iterator = getChildren().iterator();
48     while (iterator.hasNext()) {
49       Object JavaDoc o = iterator.next() ;
50       if(o instanceof UIExoComponent) {
51         UIExoComponent child = (UIExoComponent) o ;
52         child.decorate(context) ;
53       } else {
54         UIComponent child =(UIComponent) o ;
55         child.encodeBegin(context);
56         child.encodeChildren(context);
57         child.encodeEnd(context);
58       }
59     }
60   }
61 }
Popular Tags