RSS now

2001-10-03 Thread Vic Cekvenich

OK, I am arround to do an RSS.

Does RSS always have one image per channel?
How do I find available RSS feeds? Moreover?

If I can get a stupid servlet to do a simple Read 


Vic

Ted Husted wrote:

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
TITLEbean: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
TDlogic:present name=CHANNEL property=imageimg 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=2bean: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
TDh4bean:write name=ITEM property=title//h4/TD
/TR
TR
TDbean: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 

Re: RSS now

2001-10-03 Thread Peter Pilgrim


You find out about RSS from
`http://groups.yahoo.com/group/rss-dev/files/namespace.html'
This is the RSS 1.0 though
--
Peter Pilgrim  |  |++44 (0)207-545-9923
 \  \  ___   /  / ... .
-     ( * )  ---   --
_Cafe_Savannah,_San Antonio,Ibiza__



 Message History 



From: Vic Cekvenich [EMAIL PROTECTED] on 03/10/2001 00:03 MST

Please respond to [EMAIL PROTECTED]

To:   [EMAIL PROTECTED]
cc:
Subject:  RSS now


OK, I am arround to do an RSS.

Does RSS always have one image per channel?
How do I find available RSS feeds? Moreover?

If I can get a stupid servlet to do a simple Read 


Vic

Ted Husted wrote:


--CUT--


--

This e-mail may contain confidential and/or privileged information. If you are not the 
intended recipient (or have received this e-mail in error) please notify the sender 
immediately and destroy this e-mail. Any unauthorized copying, disclosure or 
distribution of the material in this e-mail is strictly forbidden.