Package org.apache.cocoon.portal.layout.renderer.aspect.impl

Source Code of org.apache.cocoon.portal.layout.renderer.aspect.impl.RemovableAspect

/*
* Copyright 1999-2002,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*      http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.cocoon.portal.layout.renderer.aspect.impl;

import org.apache.cocoon.portal.PortalService;
import org.apache.cocoon.portal.coplet.CopletInstanceData;
import org.apache.cocoon.portal.event.impl.LayoutRemoveEvent;
import org.apache.cocoon.portal.layout.Layout;
import org.apache.cocoon.portal.layout.impl.CopletLayout;
import org.apache.cocoon.portal.layout.renderer.aspect.RendererAspectContext;
import org.apache.cocoon.xml.XMLUtils;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;

/**
* Add a tag holding a URI used to remove a coplet from a layout to the
* output stream if the coplet is not set to mandatory.
*
* <h2>Example XML:</h2>
* <pre>
*   &lt;remove-uri&gt;layout-remove-event&lt;/remove-uri&gt;
*   &lt;!-- output from following renderers --&gt;
* </pre>
*
* <h2>Applicable to:</h2>
* <ul>
<li>{@link org.apache.cocoon.portal.layout.impl.CopletLayout}</li>
* </ul>
*
* @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
* @author <a href="mailto:volker.schmitt@basf-it-services.com">Volker Schmitt</a>
*
* @version CVS $Id: RemovableAspect.java 30932 2004-07-29 17:35:38Z vgritsenko $
*/
public class RemovableAspect
    extends AbstractAspect {

  /* (non-Javadoc)
   * @see org.apache.cocoon.portal.layout.renderer.RendererAspect#toSAX(org.apache.cocoon.portal.layout.renderer.RendererAspectContext, org.apache.cocoon.portal.layout.Layout, org.apache.cocoon.portal.PortalService, org.xml.sax.ContentHandler)
   */
  public void toSAX(RendererAspectContext context,
                    Layout layout,
                    PortalService service,
                    ContentHandler handler)
  throws SAXException {
       
        CopletInstanceData cid = ((CopletLayout)layout).getCopletInstanceData();

        Boolean mandatory = (Boolean)cid.getCopletData().getAspectData("mandatory");
        if ( !mandatory.booleanValue() ) {
            LayoutRemoveEvent lre = new LayoutRemoveEvent(layout);
            XMLUtils.createElement(handler, "remove-uri", service.getComponentManager().getLinkService().getLinkURI(lre));
        }
        context.invokeNext(layout, service, handler);
  }

}
TOP

Related Classes of org.apache.cocoon.portal.layout.renderer.aspect.impl.RemovableAspect

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.