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 58 public final class WindowAspect extends AbstractAspect { 59 60 63 public void toSAX(RendererAspectContext context, 64 Layout layout, 65 PortalService service, 66 ContentHandler contenthandler) 67 throws SAXException { 68 final PreparedConfiguration config = (PreparedConfiguration)context.getAspectConfiguration(); 69 final CopletInstanceData copletInstanceData = ((CopletLayout)layout).getCopletInstanceData(); 70 71 if ( config.rootTag ) { 72 XMLUtils.startElement(contenthandler, config.tagName); 73 } 74 XMLUtils.createElement(contenthandler, "title", copletInstanceData.getTitle()); 75 XMLUtils.createElement(contenthandler , "instance-id", copletInstanceData.getId()); 76 77 context.invokeNext( layout, service, contenthandler ); 78 79 if ( config.rootTag ) { 80 XMLUtils.endElement(contenthandler, config.tagName); 81 } 82 } 83 84 protected static class PreparedConfiguration { 85 public String tagName; 86 public boolean rootTag; 87 88 public void takeValues(PreparedConfiguration from) { 89 this.tagName = from.tagName; 90 this.rootTag = from.rootTag; 91 } 92 } 93 94 97 public Object prepareConfiguration(Parameters configuration) 98 throws ParameterException { 99 PreparedConfiguration pc = new PreparedConfiguration(); 100 pc.tagName = configuration.getParameter("tag-name", "window"); 101 pc.rootTag = configuration.getParameterAsBoolean("root-tag", true); 102 return pc; 103 } 104 105 } 106 | Popular Tags |