Marek Nowak wrote:
Hello

I want to write a portlet for Jetspeed2. This portlet should display a given 
html page. Let's call this portlet HtmlPortlet. I want to put 4 portlets on my 
page, each of them should display a given page.



++++++++++++++++++++++++++++++++++++++++++++++
|                      |                     |
|                      |                     |
|      HtmlPortlet     |     HtmlPortlet     |
|                      |                     |
|    displays a.html   |   displays b.html   |
|                      |                     |
|                      |                     |
++++++++++++++++++++++++++++++++++++++++++++++
|                      |                     |
|                      |                     |
|      HtmlPortlet     |     HtmlPortlet     |
|                      |                     |
|    displays c.html   |   displays d.html   |
|                      |                     |
|                      |                     |
++++++++++++++++++++++++++++++++++++++++++++++



Does anybody know how to set an "myUrl" property of these portlets? Is it possible? I 
know that properties of portlets are stored in database, but I would like to set the property 
"myUrl" in a file. If it is impossible, maybe you know how to make my application to set 
this property in database for each portlet.

Regards
Marek

Think you mean preferences.

The storage method of preferences is up to the portal impl.
You shouldn't really be concerned with the details of how the portal stores preferences...


Are you looking for an external link or a local file? We already have a web content portlet for external links in Jetspeed-2.

For a local html file, I just took 5 minutes and wrote this portlet for you.
I guess I should commit it to Gems if Ken doesnt already have something like this.
-------------------------------------------------------------------


package com.which.idtb.portlets;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import javax.portlet.PortletConfig;
import javax.portlet.PortletException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.portlet.PortletPreferences;

import org.apache.portals.bridges.common.GenericServletPortlet;

/*
 * Copyright 2000-2004 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * FilePortlet
 *
 * @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a>
 * @version $Id: $
 */
public class FilePortlet extends GenericServletPortlet
{

public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException
{
response.setContentType("text/html");
PortletPreferences prefs = request.getPreferences();
String fileName = prefs.getValue("file", null);
if (fileName != null)
{
InputStream is = this.getPortletContext().getResourceAsStream(fileName);
drain(is, response.getPortletOutputStream());
is.close();
}
else
{
response.getWriter().println("Could not find file preference ");
}
}


    static final int BLOCK_SIZE=4096;

public static void drain(InputStream r,OutputStream w) throws IOException
{
byte[] bytes=new byte[BLOCK_SIZE];
try
{
int length=r.read(bytes);
while(length!=-1)
{
if(length!=0)
{
w.write(bytes,0,length);
}
length=r.read(bytes);
}
}
finally
{
bytes=null;
}


    }


}

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to