1 package dinamica; 2 3 46 public class HGridOutput extends GenericOutput 47 { 48 49 public void print(TemplateEngine te, GenericTransaction data) 50 throws Throwable 51 { 52 53 super.print(te, data); 55 56 String rsName = getConfig().getConfigValue("hgrid-recordset"); 58 int cols = Integer.parseInt(getConfig().getConfigValue("cols")); 59 Recordset rs = (Recordset)getRequest().getAttribute(rsName); 60 String tRow = getResource(getConfig().getConfigValue("row-template")); 61 String tCol = getResource(getConfig().getConfigValue("col-template")); 62 63 StringBuffer hgrid = new StringBuffer (); 66 rs.top(); 67 for (int k=0;k<rs.getRecordCount();k=k+cols) 68 { 69 StringBuffer colsBuf = new StringBuffer (); 70 for (int i=0;i<cols;i++) 71 { 72 if (k+i==rs.getRecordCount()) 73 break; 74 rs.setRecordNumber(k+i); 75 TemplateEngine t = new TemplateEngine(getContext(),getRequest(),tCol); 76 t.replace(rs, " "); 77 colsBuf.append(t.toString()); 78 } 79 hgrid.append(StringUtil.replace(tRow,"${cols}", colsBuf.toString())); 80 } 81 82 te.replace("${hgrid}", hgrid.toString()); 84 85 } 86 } 87 | Popular Tags |