There's a menu package here  

http://husted.com/about/struts/resources.htm#extensions

that you might like to use. 

I'm working on some routines for RSS Content Syndication that use the
RSS Digester. It's not difficult. You just get a bean from the Digester
and pass it to the view. Here's a sample Action:

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.portlet.PortletDataHashMap;
import org.apache.commons.digester.rss.RSSDigester;
import org.apache.commons.digester.rss.Channel;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionServlet;

/**
 * Read and parse RSS file found at a given
 * path, save the Channel bean in request scope,
 * and forward to "continue".
 * @expects path={uri} on command line or as parameter property to
ActionMapping.
 * @expects an input page or error forwarding if exception digesting RSS
 * @author Ted Husted
 * @version $Revision:1.1 $ $Date: 2000/09/05 $
 */
public final class Fetch extends Action {

    // ---------------------------------------------------------
Instances Variables
    // --------------------------------------------------------- Public
Methods

    /**
     * Request attribute key for saving Channel bean
     */
    public static final String CHANNEL_KEY = "CHANNEL";


    /**
     * Main process of class. Reads, parses
     */
    public ActionForward perform(ActionMapping mapping,
                                 ActionForm form,
                                 HttpServletRequest request,
                                 HttpServletResponse response)
        throws IOException, ServletException {

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

        String path = request.getParameter("path");
        if (path==null) path = mapping.getParameter();
        try {
            RSSDigester digester = new RSSDigester();
            channel = (Channel) digester.parse(path);
        }
        catch (Throwable t) {
            errors.add(ActionErrors.GLOBAL_ERROR,
                new ActionError("rss.access.error"));
            servlet.log(t.toString());
        }

        // -- Handle Errors ---
        if (!errors.empty()) {
            saveErrors(request, errors);
            if (mapping.getInput()!=null)
                return (new ActionForward(mapping.getInput()));
            // If no input page, use error forwarding
            return (mapping.findForward("error"));
        }

        // -- Save Bean, and Continue  ---
        request.setAttribute(CHANNEL_KEY,channel);
        return (mapping.findForward("continue"));
    } // ---- End perform ----

} // ---- End Fetch ----

I'm about to upload a patch to the Digester that adds an getItems()
access to the Channel bean, which makes it sweet to use with bean:write.
On the view side, you just need to do something like:

<%--
/**
 * Summarize channel as unadorned HTML.
 * @parameters Channel CHANNEL
 * @author Ted Husted
 * @version $Revision: 1.1 $ $Date: 2001/09/06 $
*/
--%>
<%@ page language="java" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<html:html/>
<HEAD>
<TITLE><bean:write name="CHANNEL" property="title"/></TITLE>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<html:base/>
</HEAD>
<BODY>
<TABLE cellspacing="2" cellpadding="4" width="90%" align="center">
<TR>
<TD><logic:present name="CHANNEL" property="image"><img src="<bean:write
name="CHANNEL" property="image.URL"/>"></logic:present></TD>
<TD width="100%"><a href="<bean:write name="CHANNEL" property="link"/>">
<bean:write name="CHANNEL" property="title"/></a></TD>
</TR>
<TD colspan="2"><bean:write name="CHANNEL" property="description"/></TD>
</TR>
</TABLE>
<logic:iterate name="CHANNEL" property="items" id="ITEM">
<HR width="90%">
<TABLE cellspacing="2" cellpadding="4" width="90%" align="center">
<TR>
<TD><h4><bean:write name="ITEM" property="title"/></h4></TD>
</TR>
<TR>
<TD><bean:write name="ITEM" property="description"/></TD>
</TR>
<TR>
<TD align="right">... <a href="<bean:write name="ITEM"
property="link"/>">more</a></TD>
</TR>
</TABLE>
</logic:iterate>
<HR width="90%">
</BODY>
</HTML>

This uses the updates version of Struts-digester from the Commons, that
I just committed, and that should be in tomorrow's snapshot <
http://jakarta.apache.org/builds/jakarta-commons/nightly/commons-digester/
>.

But, this is not something that needs to be the framework, just in some
sample applications. Cedric or I will probably add a RSS example to the
Tiles tutorial. 

Ditto for PDF. All you need is something that would return the PDF via
the Response, and then return NULL to the controller. The frameworks
isn't really involved. 

Anything that is being actively considered would be on the TODO list.
There are no other development discussion areas beside the Struts-Dev
list. 

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/about/struts/


Vic Cekvenich wrote:
> 
> 
> Is there thinking that soone there will be a menu included in struts
> distribution (1.1a or 1.2)?
>     There are a few out, which is the most popular to use in my app?
> 
> What about RSS content syndication recomendation? PDF support?
> 
> My 2c and Questions,
> Vic

Reply via email to