You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by Sebastian Komander <se...@gehacked.org> on 2005/08/06 15:30:29 UTC

One portlet on multiple pages but different parameters

Hi...


I want to create a portlet which shows articles. I want to place this
portlet on many pages. Then, i want to set a parameter which is different
for every page. Example:

Portlet is placed on page1, page2, page3, page4, page5. The parameter is
named "type".

Portlet on page1: type="a"
Portlet on page2: type="b"
Portlet on page3: type="c"
Portlet on page4: type="d"
Portlet on page5: type="e"

I want to do this without copying the portlet 5 times. Is this possible ?
The parameter should be saved in the portlet preferences or where ever it
is possible.

In WebSphere Portlet is this possible, does it work in Jetspeed2-M3 also ?

Can you tell me how this works ?

kind regards

Sebastian


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


RE: One portlet on multiple pages but different parameters

Posted by David Pankros <dp...@miragy.com>.
You can also subclass your portlet and make the "type" static for each
subclass.  Then name each portlet accordingly.  E.g.:

Portlet Name
PersonListedByFather
PersonListedByMother
PersonListedByFamilyName
...

Instead of
Person (type="byFather")
Person (type="byMother")
Person (type="byFamilyName")
...

If you encapsulated your code well, taking that approach would be fairly
trivial as a overloaded "getType()" call could be one of the only
methods in each of the subclasses.  In this case, this approach seems
more favorable to me than trying to create some clever way of storing
your own parameters.

HTH.

Dave

-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.10.4/66 - Release Date: 8/9/2005
 


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: One portlet on multiple pages but different parameters

Posted by Jilles van Gurp <in...@jillesvangurp.com>.
I had a similar problem. The problem with preferences is that they are 
per user. They are therefore not suitable for portlet configuration 
because configuration should be the same for all users. I eventually 
solved it in the following way:

I use commons-configuration from apache which allows you to save 
properties to a properties file. I use RenderResponse.getNamespace() to 
get a name that is unique per portlet instance. As far as I know this is 
the only way you can get a portlet instance specific identifier for your 
portlet instance. This + .properties becomes the filename for the 
portlet properties file so each instance has its own persistent 
properties store. I use an init param to specify the location for the 
properties files. The first time the portlets are displayed, they create 
their own properties file if one doesn't exist. I adjust the properties 
in the edit mode of the portlet and the processAction saves the changes 
to the properties file.

Unfortunately the problem of configuration is not solved very well in 
jsr168. JSR168 specifies that you can use the same portlet multiple 
times but doesn't specify a way to identify the instances. The namespace 
trick described above is a hack. A major disadvantage is that jsr168 
doesn't specifiy what the namespace should look like so you can't 
configure the portlets upfront (because you don't know what the 
namespace will be) and have to wait for the portlet to create the 
properties file. An additional problem may be that the namespace string 
is not suitable for use as a filename (not an issue in jetspeed).

Otherwise this works fine for me.What I would prefer is that each 
portlet instance would be assigned a name by the portal and that each 
instance has its own parameters. Of course this is how many portals 
probably work but it is not part of JSR 168 so you can't take this 
behaviour for granted.

Regards,

Jilles van Gurp

Scott T Weaver wrote:
> You would probably be better off using portlet preferences as opposed to
> init parameters.
>
>
> Hth,
> Scott
>
>   
>> -----Original Message-----
>> From: Sebastian Komander [mailto:seb@gehacked.org]
>> Sent: Saturday, August 06, 2005 9:30 AM
>> To: jetspeed-user@portals.apache.org
>> Subject: One portlet on multiple pages but different parameters
>>
>> Hi...
>>
>>
>> I want to create a portlet which shows articles. I want to place this
>> portlet on many pages. Then, i want to set a parameter which is different
>> for every page. Example:
>>
>> Portlet is placed on page1, page2, page3, page4, page5. The parameter is
>> named "type".
>>
>> Portlet on page1: type="a"
>> Portlet on page2: type="b"
>> Portlet on page3: type="c"
>> Portlet on page4: type="d"
>> Portlet on page5: type="e"
>>
>> I want to do this without copying the portlet 5 times. Is this possible ?
>> The parameter should be saved in the portlet preferences or where ever it
>> is possible.
>>
>> In WebSphere Portlet is this possible, does it work in Jetspeed2-M3 also ?
>>
>> Can you tell me how this works ?
>>
>> kind regards
>>
>> Sebastian
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
>> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>>     
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>
>
>
>   


RE: One portlet on multiple pages but different parameters

Posted by Scott T Weaver <sc...@binary-designs.net>.
You would probably be better off using portlet preferences as opposed to
init parameters.


Hth,
Scott

> -----Original Message-----
> From: Sebastian Komander [mailto:seb@gehacked.org]
> Sent: Saturday, August 06, 2005 9:30 AM
> To: jetspeed-user@portals.apache.org
> Subject: One portlet on multiple pages but different parameters
> 
> Hi...
> 
> 
> I want to create a portlet which shows articles. I want to place this
> portlet on many pages. Then, i want to set a parameter which is different
> for every page. Example:
> 
> Portlet is placed on page1, page2, page3, page4, page5. The parameter is
> named "type".
> 
> Portlet on page1: type="a"
> Portlet on page2: type="b"
> Portlet on page3: type="c"
> Portlet on page4: type="d"
> Portlet on page5: type="e"
> 
> I want to do this without copying the portlet 5 times. Is this possible ?
> The parameter should be saved in the portlet preferences or where ever it
> is possible.
> 
> In WebSphere Portlet is this possible, does it work in Jetspeed2-M3 also ?
> 
> Can you tell me how this works ?
> 
> kind regards
> 
> Sebastian
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: AW: One portlet on multiple pages but different parameters

Posted by Santiago Gala <sg...@apache.org>.
El lun, 08-08-2005 a las 08:48 +0200, Sven Thiergen escribió:
> Von: Sebastian Komander [mailto:seb@gehacked.org]
> Gesendet: Samstag, 6. August 2005 15:30
> An: jetspeed-user@portals.apache.org
> Betreff: One portlet on multiple pages but different parameters
> 
> > Hi...
> >
> >
> > I want to create a portlet which shows articles. I want to place
> > this portlet on many pages. Then, i want to set a parameter which
> > is different for every page. Example:
> >
> > Portlet is placed on page1, page2, page3, page4, page5. The
> > parameter is named "type".
> >
> > ...
> >
> > I want to do this without copying the portlet 5 times. Is this
> > possible? The parameter should be saved in the portlet preferences
> > or where ever it is possible.
> 
> If you have 5 different PSML pages for this (I guess you need them, anyway)
> you should be able to access its parameters (skin, fragment id) via some
> Jetspeed internal object; bound in the request:
> 
>   Object layoutObject = request.getAttribute(...);
> 
>   where "Object" needs to be casted in some Jetspeed thingy.
> 
> Does someone know the correct attribute key for this? Otherwise just iterate
> over your request object; you'll be suprised what you are going to find in
> it. ;-)   Maybe there is a cleaner solution for this; I don't think it is
> good design to access Jetspeed's core objects from a simple portlet.
> 

Non specified attributes in the request are likely to change or
disappear. You should not trust them as being there, as security or
efficiency constrains can make us remove them.

I recently wrote a python portlet, as part of the python bridge that
will land soon in svn, and I found way too many attributes are "leaked"
to the webapp requests. I plan to take a look into this.

Part of the reason this is going on is the fact that there is no
standard JSR-168 way to advertise, discover and get services. 

Regards
Santiago

> 
> Sven.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
> 
-- 
VP and Chair, Apache Portals (http://portals.apache.org)
Apache Software Foundation


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


AW: One portlet on multiple pages but different parameters

Posted by Sven Thiergen <s....@itcampus.de>.
Von: Sebastian Komander [mailto:seb@gehacked.org]
Gesendet: Samstag, 6. August 2005 15:30
An: jetspeed-user@portals.apache.org
Betreff: One portlet on multiple pages but different parameters

> Hi...
>
>
> I want to create a portlet which shows articles. I want to place
> this portlet on many pages. Then, i want to set a parameter which
> is different for every page. Example:
>
> Portlet is placed on page1, page2, page3, page4, page5. The
> parameter is named "type".
>
> ...
>
> I want to do this without copying the portlet 5 times. Is this
> possible? The parameter should be saved in the portlet preferences
> or where ever it is possible.

If you have 5 different PSML pages for this (I guess you need them, anyway)
you should be able to access its parameters (skin, fragment id) via some
Jetspeed internal object; bound in the request:

  Object layoutObject = request.getAttribute(...);

  where "Object" needs to be casted in some Jetspeed thingy.

Does someone know the correct attribute key for this? Otherwise just iterate
over your request object; you'll be suprised what you are going to find in
it. ;-)   Maybe there is a cleaner solution for this; I don't think it is
good design to access Jetspeed's core objects from a simple portlet.


Sven.


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org