1 package fr.improve.struts.taglib.layout.util; 2 3 import java.util.ArrayList ; 4 import java.util.List ; 5 6 import javax.servlet.jsp.JspException ; 7 import javax.servlet.jsp.PageContext ; 8 import javax.servlet.jsp.tagext.TagSupport ; 9 10 import fr.improve.struts.taglib.layout.collection.BaseCollectionTag; 11 12 18 public class NewsCollection extends BasicPanel implements CollectionInterface { 19 private List headers = new ArrayList (); 20 private PanelInterface innerPanel = new BasicPanel(); 21 private BaseCollectionTag collectionTag; 22 25 public void init(PageContext pg, String in_styleClass, TagSupport in_panel) throws JspException { 26 super.init(pg, in_styleClass, in_panel); 27 headers.clear(); 28 innerPanel.init(pg, in_styleClass, in_panel); 29 collectionTag = (BaseCollectionTag) in_panel; 30 } 31 34 public void doPrintEmptyCollection(StringBuffer out_buffer, String in_message) { 35 out_buffer.append("<tr><td><span class=\""); 36 out_buffer.append(styleClass); 37 out_buffer.append("\"> "); 38 out_buffer.append(in_message); 39 out_buffer.append("</span></td></tr>"); 40 } 41 44 public void doPrintTitle(StringBuffer buffer, String title) { 45 if (title!=null) { 46 if (isNested) { 47 buffer.append("<tr><td colspan=\""); 48 buffer.append(colspan); 49 buffer.append("\">"); 50 } 51 if (styleClass!=null) { 52 buffer.append("<p class=\""); 53 buffer.append(styleClass); 54 buffer.append("\">"); 55 } 56 buffer.append(title); 57 if (styleClass!=null) { 58 buffer.append("</p>"); 59 } 60 if (isNested) { 61 buffer.append("</td></tr>"); 62 } 63 } 64 } 65 68 public void doStartHeaders(StringBuffer out_buffer) { 69 } 71 74 public void doPrintHeader(StringBuffer out_buffer, String in_header, String in_width, String in_sortUrl) { 75 headers.add(in_header); 77 } 78 81 public void doEndHeaders(StringBuffer out_buffer) { 82 } 84 87 public void doStartItems(StringBuffer out_buffer) { 88 innerPanel.doStartPanel(out_buffer, "center", collectionTag.getWidth()); 89 } 90 93 public void doPrintItem(StringBuffer out_buffer, String in_item, String [] in_styleClass, String in_id) { 94 if (collectionTag.getColumn()==0) { 95 innerPanel.doPrintTitle(out_buffer, in_item); 96 out_buffer.append("<tr><td class=\""); 97 out_buffer.append(in_styleClass[0]); 98 out_buffer.append("\"><table border=0>"); 99 } else { 100 out_buffer.append("<tr><td align=right class="); 101 out_buffer.append(styleClass); 102 out_buffer.append(">"); 103 out_buffer.append(headers.get(collectionTag.getColumn())); 104 out_buffer.append(" : </td><td class="); 105 out_buffer.append(in_styleClass[0]); 106 out_buffer.append(">"); 107 out_buffer.append(in_item); 108 out_buffer.append("</td></tr>"); 109 } 110 } 111 114 public void doEndItems(StringBuffer out_buffer) { 115 out_buffer.append("</table></td></tr>"); 116 innerPanel.doEndPanel(out_buffer); 117 out_buffer.append("<br>\n"); 118 } 119 public void doStartPanel(StringBuffer buffer, String align, String width) { 120 if (isNested) { 121 buffer.append("<tr><td colspan=\"2\">\n"); 122 } 123 } 124 public void doEndPanel(StringBuffer buffer) { 125 if (isNested) { 126 buffer.append("</td></tr>\n"); 127 } 128 } 129 } | Popular Tags |