Christian thank you very much. Plugged your code in and got that working in
about 10 minutes!

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Christian Sell
Sent: Tuesday, October 24, 2000 5:33 PM
To: JetSpeed
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]

Reply via email to