All, I am having an issue where the preferences are reset when I redeploy my portlet application. This seems like it should be a bug, would others agree?
On Thu, 20 Jan 2005 11:02:07 +0100, Marek Nowak <[EMAIL PROTECTED]> wrote: > Thanks David, you helped me a lot. So I understand that for each instance of > my HtmlPortlet I can have a set of preferences. So HtmlPortlet that is > displayed as the first one at the page can have preference "file" set to > "a.html", the same portlet that is displayed as the second one at the page > can have preference "file" set to "b.html". Am I right? > > I want to do something like this: > > MyApplication : > - creates psml file (which contains 4 instances of HtmlPortlet) > - for each instance of portlet sets "file" preference to a proper value > <-------- How can I do this? > > Regards > Marek > > > ----- Original Message ----- > From: "David Sean Taylor" <[EMAIL PROTECTED]> > To: "Jetspeed Users List" <[email protected]> > Sent: Wednesday, January 19, 2005 7:21 PM > Subject: Re: portlet property > > > 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] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
