Example usage for org.apache.commons.digester.rss Channel render

List of usage examples for org.apache.commons.digester.rss Channel render

Introduction

In this page you can find the example usage for org.apache.commons.digester.rss Channel render.

Prototype

public void render(PrintWriter writer) 

Source Link

Document

Render this channel as XML conforming to the RSS 0.91 specification, to the specified writer, with no indication of character encoding.

Usage

From source file:org.apache.struts.scaffold.rss.RenderRss.java

/**
 (* // :FIXME: Hasn't been tested./*from ww  w  .java2 s  .c  o m*/
 * Retrieves a Digester Channel bean from request context and
 * renders it.
 * <p>
 * Channel bean must be stored under the attribute
 * ParseRss.CHANNEL_KEY or under an attribute given as the
 * parameter property.
 *
 * @param mapping The ActionMapping used to select this instance
 * @param form The optional ActionForm bean for this request
 * @param request The HTTP request we are processing
 * @param response The resonse we are creating
 * @fixme Use ActionForwards for links instead of properties
 */
public void executeLogic(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    ActionErrors errors = new ActionErrors();
    Channel channel = null;

    try {
        channel = (Channel) request.getAttribute(ParseRss.CHANNEL_KEY);
    } catch (Throwable t) {
        channel = null;
    }

    if (null == channel) {
        try {
            channel = (Channel) request.getAttribute(mapping.getParameter());
        } catch (Throwable t) {
            channel = null;
        }
    }

    if (null == channel) {
        errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(Tokens.PROCESS_MISSING_PARAMETER));
    }

    if (errors.empty()) {
        response.setContentType(Tokens.TEXT_PLAIN);
        channel.render(response.getWriter());
    }

    else {
        // This will trigger findFailure() in the BaseAction
        saveErrors(request, errors);
    }

}