1 5 package org.exoplatform.portlet.faces.component; 6 7 import java.util.* ; 8 import java.io.IOException ; 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 19 public class UIExoViewRoot extends UIViewRoot { 20 private boolean isComponentView_ ; 21 22 public UIExoViewRoot(String viewId) { 23 super() ; 24 isComponentView_ = false ; 25 setViewId(viewId) ; 26 if (viewId.endsWith(".class")) { 27 String 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 clazz) { 36 try { 37 UIComponentFactory factory = new UIComponentFactory() ; 38 UIComponent component = (UIComponent) factory.createUIComponent(clazz); 39 return component ; 40 } catch (Throwable t) { 41 t.printStackTrace() ; 42 } 43 return null ; 44 } 45 46 public void renderChildren( FacesContext context) throws IOException { 47 Iterator iterator = getChildren().iterator(); 48 while (iterator.hasNext()) { 49 Object 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 |