1 16 package org.apache.myfaces.custom.panelstack; 17 18 import javax.faces.component.html.HtmlPanelGroup; 19 import javax.faces.context.FacesContext; 20 21 import javax.faces.el.ValueBinding; 22 23 24 43 public class HtmlPanelStack extends HtmlPanelGroup 44 { 45 46 public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlPanelStack"; 47 public static final String COMPONENT_FAMILY = "javax.faces.Panel"; 48 private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.PanelStack"; 49 50 private String selectedPanel = null; 51 52 public HtmlPanelStack() 53 { 54 setRendererType(DEFAULT_RENDERER_TYPE); 55 } 56 57 public String getFamily() 58 { 59 return COMPONENT_FAMILY; 60 } 61 62 public void setSelectedPanel(String selectedPanel) 63 { 64 this.selectedPanel = selectedPanel; 65 } 66 67 public String getSelectedPanel() 68 { 69 if (selectedPanel != null) return selectedPanel; 70 ValueBinding vb = getValueBinding("selectedPanel"); 71 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 72 } 73 74 public Object saveState(FacesContext context) 75 { 76 Object values[] = new Object [2]; 77 values[0] = super.saveState(context); 78 values[1] = selectedPanel; 79 return ((Object ) (values)); 80 } 81 82 public void restoreState(FacesContext context, Object state) 83 { 84 Object values[] = (Object [])state; 85 super.restoreState(context, values[0]); 86 selectedPanel = (String )values[1]; 87 } 88 } 89 | Popular Tags |