1 16 package org.apache.cocoon.portal.layout.renderer.aspect.impl; 17 18 import org.apache.avalon.framework.parameters.ParameterException; 19 import org.apache.avalon.framework.parameters.Parameters; 20 import org.apache.cocoon.portal.PortalService; 21 import org.apache.cocoon.portal.coplet.CopletInstanceData; 22 import org.apache.cocoon.portal.layout.Layout; 23 import org.apache.cocoon.portal.layout.impl.CopletLayout; 24 import org.apache.cocoon.portal.layout.renderer.aspect.RendererAspectContext; 25 import org.apache.cocoon.xml.XMLUtils; 26 import org.xml.sax.ContentHandler ; 27 import org.xml.sax.SAXException ; 28 29 62 public class CIncludeCopletAspect 63 extends AbstractCIncludeAspect { 64 65 68 public void toSAX(RendererAspectContext context, 69 Layout layout, 70 PortalService service, 71 ContentHandler handler) 72 throws SAXException { 73 final PreparedConfiguration config = (PreparedConfiguration)context.getAspectConfiguration(); 74 final CopletInstanceData cid = ((CopletLayout)layout).getCopletInstanceData(); 75 if (!(context.isRendering())) { 76 context.invokeNext(layout, service, handler); 77 } 78 if ( config.rootTag) { 79 XMLUtils.startElement(handler, config.tagName); 80 } 81 82 this.createCInclude("coplet://" + cid.getId(), handler); 83 84 if ( config.rootTag) { 85 XMLUtils.endElement(handler, config.tagName); 86 } 87 88 context.invokeNext(layout, service, handler); 89 } 90 91 protected static class PreparedConfiguration { 92 93 public String tagName; 94 public boolean rootTag; 95 96 public void takeValues(PreparedConfiguration from) { 97 this.tagName = from.tagName; 98 this.rootTag = from.rootTag; 99 } 100 } 101 102 105 public Object prepareConfiguration(Parameters configuration) 106 throws ParameterException { 107 PreparedConfiguration pc = new PreparedConfiguration(); 108 pc.tagName = configuration.getParameter("tag-name", "content"); 109 pc.rootTag = configuration.getParameterAsBoolean("root-tag", true); 110 return pc; 111 } 112 113 } 114 | Popular Tags |