1 9 10 package org.jboss.portal.core.theme.render.impl; 11 12 import org.apache.log4j.Logger; 13 import org.jboss.portal.server.output.FragmentResult; 14 import org.jboss.portal.server.theme.Item; 15 import org.jboss.portal.server.theme.Region; 16 import org.jboss.portal.server.theme.RegionOrientation; 17 import org.jboss.portal.server.theme.render.RegionRenderer; 18 import org.jboss.portal.server.theme.render.RenderContext; 19 import org.jboss.portal.server.theme.render.RenderException; 20 21 import java.util.Iterator ; 22 23 30 public class TableRegionRenderer 31 implements RegionRenderer 32 { 33 private static Logger log = Logger.getLogger(TableRegionRenderer.class); 34 35 public TableRegionRenderer() 36 { 37 } 38 39 42 public void renderStart(RenderContext ctx) 43 { 44 log.debug(ctx.getRegionOrientation().toString()); 45 46 if (ctx.getRegionOrientation() == RegionOrientation.HORIZONTAL) 47 { 48 ctx.getMarkupFragment().append("<table class='horizontalRegion'><tr>"); 50 } 51 else 52 { 53 ctx.getMarkupFragment().append("<table class='verticalRegion'>"); 55 } 56 } 57 58 61 public void render(RenderContext ctx, Region region) throws RenderException 62 { 63 log.debug("starting with: " + ctx.getMarkupFragment()); 64 65 if (region.isEmpty()) 66 { 67 log.debug("region is empty: nothing to render!"); 68 return; 69 } 70 71 renderStart(ctx); 72 73 for (Iterator i = region.items(); i.hasNext();) 74 { 75 Item item = (Item)i.next(); 76 FragmentResult fragment = item.getFragment(); 77 78 if (ctx.getRegionOrientation() == RegionOrientation.HORIZONTAL) 79 { 80 ctx.getMarkupFragment().append("<td class='horizontalRegionElement'>"); 82 ctx.getWindowRenderer().render(ctx, fragment); 83 ctx.getMarkupFragment().append("</td>"); 84 } 85 else 86 { 87 ctx.getMarkupFragment().append("<tr><td class='verticalRegionElement'>"); 89 ctx.getWindowRenderer().render(ctx, fragment); 90 ctx.getMarkupFragment().append("</td></tr>"); 91 } 92 } 93 94 renderEnd(ctx); 95 96 log.debug("ending with: " + ctx.getMarkupFragment()); 97 } 98 99 102 public void renderEnd(RenderContext ctx) 103 { 104 if (ctx.getRegionOrientation() == RegionOrientation.HORIZONTAL) 105 { 106 ctx.getMarkupFragment().append("</tr></table>"); 108 } 109 else 110 { 111 ctx.getMarkupFragment().append("</table>"); 113 } 114 } 115 } 116 | Popular Tags |