1 16 package org.apache.myfaces.custom.newspaper; 17 18 import javax.faces.component.UIComponent; 19 import javax.faces.context.FacesContext; 20 import javax.faces.component.html.HtmlDataTable; 21 22 27 public class HtmlNewspaperTable 28 extends HtmlDataTable 29 { 30 31 public static final String RENDERER_TYPE = "org.apache.myfaces.HtmlNewspaperTable"; 32 public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlNewspaperTable"; 33 34 35 public static final String NEWSPAPER_COLUMNS_PROPERTY = "newspaperColumns"; 36 public static final String SPACER_FACET_NAME = "spacer"; 37 38 39 private int newspaperColumns = 1; 40 41 public HtmlNewspaperTable() { 42 setRendererType(RENDERER_TYPE); 43 } 44 45 48 public int getNewspaperColumns() { 49 return newspaperColumns; 50 } 51 public void setNewspaperColumns(int newspaperColumns) { 52 this.newspaperColumns = newspaperColumns; 53 } 54 55 58 public UIComponent getSpacer() { 59 return (UIComponent)getFacets().get(SPACER_FACET_NAME); 60 } 61 public void setSpacer(UIComponent spacer) { 62 getFacets().put(SPACER_FACET_NAME, spacer); 63 } 64 65 public Object saveState(FacesContext context) { 66 Object values[] = new Object [2]; 67 values[0] = super.saveState(context); 68 values[1] = new Integer (newspaperColumns); 69 return values; 70 } 71 72 public void restoreState(FacesContext context, Object state) { 73 Object values[] = (Object [])state; 74 super.restoreState(context, values[0]); 75 newspaperColumns = ((Integer )values[1]).intValue(); 76 } 77 } | Popular Tags |