Skip to content

Commit

Permalink
Clean up full screen implementation. Does not require aspects to part…
Browse files Browse the repository at this point in the history
…icipate.

git-svn-id: https://svn.apache.org/repos/asf/cocoon/branches/BRANCH_2_1_X@331660 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
rgoers committed Nov 8, 2005
1 parent 8a45c82 commit f27d3c9
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,10 @@ public void toSAX(RendererAspectContext context,
throws SAXException {
if ( layout instanceof CompositeLayout) {
CompositeLayout compositeLayout = (CompositeLayout)layout;
Layout entryLayout = service.getEntryLayout(null);
// loop over all rows
for (Iterator iter = compositeLayout.getItems().iterator(); iter.hasNext();) {
Item item = (Item) iter.next();
if (entryLayout != null) {
Layout itemLayout = item.getLayout();
if (itemLayout == entryLayout) {
service.setRenderable(Boolean.TRUE);
this.processLayout(itemLayout, service, handler);
return;
}
if (itemLayout instanceof CompositeLayout) {
this.processLayout(itemLayout, service, handler);
}
} else {
this.processItem(item, handler, service);
}
this.processItem(item, handler, service);
}
} else {
throw new SAXException("CompositeLayout expected.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,11 @@ public void toSAX(RendererAspectContext context,
ContentHandler handler)
throws SAXException {
PreparedConfiguration config = (PreparedConfiguration)context.getAspectConfiguration();
boolean renderable = context.isRendering();
if ( config.rootTag && renderable) {
if ( config.rootTag) {
XMLUtils.startElement(handler, config.tagName);
}
super.toSAX(context, layout, service, handler);
if ( config.rootTag && renderable) {
if ( config.rootTag) {
XMLUtils.endElement(handler, config.tagName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@

import org.apache.cocoon.portal.PortalService;
import org.apache.cocoon.portal.layout.Layout;
import org.apache.cocoon.portal.layout.CompositeLayout;
import org.apache.cocoon.portal.layout.Item;
import org.apache.cocoon.portal.layout.renderer.aspect.RendererAspect;
import org.apache.cocoon.portal.layout.renderer.aspect.RendererAspectContext;
import org.apache.cocoon.portal.layout.renderer.Renderer;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;

Expand All @@ -44,11 +47,21 @@ public final class DefaultRendererContext implements RendererAspectContext {
private Map attributes;
private Map objectModel;
private boolean isRendering;
private boolean isRequired;

public DefaultRendererContext(RendererAspectChain chain, boolean isRendering) {
public DefaultRendererContext(RendererAspectChain chain, Layout layout, PortalService service) {
this.iterator = chain.getIterator();
this.configIterator = chain.getConfigIterator();
this.isRendering = chain.isRequired() || isRendering;
this.isRequired = chain.isRequired();
Layout entryLayout = service.getEntryLayout(null);
if (service.isRenderable().booleanValue()) {
this.isRendering = true;
return;
}
if (entryLayout == layout) {
this.isRendering = true;
service.setRenderable(Boolean.TRUE);
}
}

/* (non-Javadoc)
Expand All @@ -58,7 +71,21 @@ public void invokeNext(Layout layout,
PortalService service,
ContentHandler handler)
throws SAXException {
if (iterator.hasNext()) {
if (!this.isRendering && !this.isRequired) {
if (layout instanceof CompositeLayout) {
CompositeLayout compositeLayout = (CompositeLayout)layout;
for (Iterator iter = compositeLayout.getItems().iterator(); iter.hasNext();) {
Layout itemLayout = ((Item) iter.next()).getLayout();
if ( itemLayout != null ) {
final String rendererName = itemLayout.getRendererName();
final Renderer renderer = service.getComponentManager().getRenderer(rendererName);
renderer.toSAX(itemLayout, service, handler);
}
}
}
return;
}
if (iterator.hasNext()) {
this.config = this.configIterator.next();
final RendererAspect aspect = (RendererAspect) iterator.next();
aspect.toSAX(this, layout, service, handler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ public void toSAX(RendererAspectContext context,

final PreparedConfiguration config = (PreparedConfiguration)context.getAspectConfiguration();

if (!(context.isRendering())) {
context.invokeNext( layout, service, contenthandler );
return;
}
Map parameter = layout.getParameters();
if (parameter.size() > 0) {
AttributesImpl attributes = new AttributesImpl();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@ public void toSAX(RendererAspectContext context,
final PreparedConfiguration config = (PreparedConfiguration)context.getAspectConfiguration();
final CopletInstanceData copletInstanceData = ((CopletLayout)layout).getCopletInstanceData();

if (!(context.isRendering())) {
context.invokeNext( layout, service, contenthandler );
return;
}

if ( config.rootTag ) {
XMLUtils.startElement(contenthandler, config.tagName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ public void toSAX(RendererAspectContext context,
final PreparedConfiguration config = (PreparedConfiguration)context.getAspectConfiguration();
final CopletInstanceData copletInstanceData = ((CopletLayout)layout).getCopletInstanceData();

if (!(context.isRendering())) {
context.invokeNext( layout, service, contenthandler );
return;
}
if ( config.rootTag ) {
XMLUtils.startElement(contenthandler, config.tagName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,6 @@ public void toSAX(RendererAspectContext context,
PortalService service,
ContentHandler handler)
throws SAXException {
if (!(context.isRendering())) {
context.invokeNext( layout, service, handler );
return;
}
PreparedConfiguration config = (PreparedConfiguration)context.getAspectConfiguration();

XSLTProcessor processor = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@ public void service(ServiceManager manager) throws ServiceException {
* Stream out raw layout
*/
public void toSAX(Layout layout, PortalService service, ContentHandler handler) throws SAXException {
DefaultRendererContext renderContext = new DefaultRendererContext(this.chain, service.isRenderable().booleanValue());
Boolean isRenderable = service.isRenderable();
DefaultRendererContext renderContext = new DefaultRendererContext(this.chain, layout, service);
renderContext.setObjectModel(ContextHelper.getObjectModel(this.context));
renderContext.invokeNext(layout, service, handler);
service.setRenderable(isRenderable);
}

/* (non-Javadoc)
Expand Down

0 comments on commit f27d3c9

Please sign in to comment.