Christian,
I tried your implementation of EcsJSPElement (together with a JspPortlet
that gets its content from a JSP). All looks to be working allright, however
I see that the content of the JSP appears on top of my Jetspeed home page
and not in it's Portlet box. Also the JSP element that gets constructed
appears "empty"?
I'm not familiar with ECS. Do you have any idea what it is I am doing wrong?
Thanks,
Rogier
----- Original Message -----
From: "Christian Sell" <[EMAIL PROTECTED]>
To: "JetSpeed" <[EMAIL PROTECTED]>
Sent: Wednesday, October 25, 2000 02:33
Subject: Re: JSP portlet
> I have done something similar a while ago. Basically, I implemented an
> EcsElement, which I returned from the Portlet.getContent(). At the end of
> the message you find the code for the Ecs class, which has been adapted
for
> this list, it probably does not compile as is. The getContent() may look
> like this:
>
> public ConcreteElement getContent() {
>
> return new EcsJSPElement(rundata, url);
> }
>
> You could also define the EcsJSPElement as an anonymous inner class in the
> above method.
>
> Hope this helps,
> Christian
>
>
> import org.apache.ecs.GenericElement;
> import org.apache.ecs.Element;
>
> import java.io.IOException;
> import java.io.OutputStream;
> import java.io.PrintWriter;
> import java.io.OutputStreamWriter;
>
> /**
> * encapsulates a JSP within the context of ECS
> * HTML-generation. I dont particularily like this.
> */
> public class EcsJSPElement extends GenericElement
> {
> private String theUrl;
> private Rundata rundata;
>
> public Element addElementToRegistry(Element element)
> {return element;}
> public Element addElementToRegistry(String element)
> {return null;}
> public Element removeElementFromRegistry(Element element)
> {return element;}
> public Element removeElementFromRegistry(String element)
> {return null;}
> public boolean registryHasElement(Element element)
> {return false;}
> public boolean registryHasElement(String element)
> {return false;}
>
> public EcsJSPElement(Rundata rundata, String urlString)
> {
> this.theUrl = urlString;
> this.rundata = rundata;
> }
> public void output(OutputStream out)
> {
> output(new PrintWriter(out));
> }
>
> /**
> Add element to the designated PrintWriter.
> */
> public void output(PrintWriter out)
> {
> ServletContext ctx = rundata.getServletContext();
> RequestDispatcher dispatcher = ctx.getRequestDispatcher(url);
> try
> {
> // include the JSP. Maybe flush first?
>
> dispatcher.include(rundata.getRequest(),
> rundata.getResponse());
> } catch (Exception e) {
> String message = "JSPPortlet: Could not include the following
> URL: " + url + " : " + e.getMessage();
> Log.error( message, e );
> out.print(message);
> }
> }
> }
>
>
>
>
> --
> --------------------------------------------------------------
> Please read the FAQ! <http://java.apache.org/faq/>
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
> Archives and Other: <http://java.apache.org/main/mail.html>
> Problems?: [EMAIL PROTECTED]
>
>
--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Archives and Other: <http://java.apache.org/main/mail.html>
Problems?: [EMAIL PROTECTED]