1 16 package org.apache.myfaces.custom.panelstack; 17 18 import org.apache.myfaces.renderkit.RendererUtils; 19 import org.apache.myfaces.renderkit.html.HtmlRenderer; 20 21 import javax.faces.component.UIComponent; 22 import javax.faces.context.FacesContext; 23 import java.io.IOException ; 24 25 26 46 public class HtmlPanelStackRenderer extends HtmlRenderer 47 { 48 49 50 public void encodeBegin(FacesContext facesContext, UIComponent uiComponent) throws IOException 51 { 52 } 53 54 55 public boolean getRendersChildren() 56 { 57 return true; 58 } 59 60 61 public void encodeChildren(FacesContext facescontext, UIComponent uicomponent) throws IOException 62 { 63 } 64 65 66 public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException 67 { 68 RendererUtils.checkParamValidity(facesContext, uiComponent, HtmlPanelStack.class); 69 70 HtmlPanelStack panelStack = (HtmlPanelStack) uiComponent; 71 String selectedPanel = panelStack.getSelectedPanel(); 72 UIComponent childToRender = null; 73 74 if (selectedPanel == null) 75 { 76 if (panelStack.getChildCount() > 0) { 78 childToRender = (UIComponent) panelStack.getChildren().get(0); 79 } 80 } else 81 { 82 childToRender = panelStack.findComponent(selectedPanel); 84 if (childToRender == null) 85 { 86 if (panelStack.getChildCount() > 0) { 88 childToRender = (UIComponent) panelStack.getChildren().get(0); 89 } 90 } 91 } 92 93 if (childToRender != null) 94 { 95 RendererUtils.renderChild(facesContext, childToRender); 96 } 97 } 98 99 } 100 | Popular Tags |