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 je...@theunderground.net on 2006/01/22 02:26:33 UTC

Retrieving a portlet's unique instance ID..

All,

Okay, so I have a portal that will have multiple instances of my content
display portlet.  But each instance of my portlet needs to have a way of
retrieving some ID that differentiates it from all the other, identical
content display portlets.  This ID should not only be unique to this
portlet instance, but also persistant across server restarts.

Is this possible in Jetspeed 2?

-Ben



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


Re: Retrieving a portlet's unique instance ID..

Posted by Jacek Wiślicki <ja...@gmail.com>.
Wiadomosc od jetspeed@theunderground.net z 2006-01-23 22:02 brzmiala:

> Anyone out there have thoughts on this?  Am I thinking about this
> incorrectly, or is this a time when a portlet has a legitimate reason for
> fetching a unique identifier?
And using fragment IDs works fine in this situation. The case of manual 
setting preferences has another drawback - the default j2-admin 
application displays only a list of fragment identifiers and it is very 
difficult (impossible?) to identify the fragment one needs, especially 
in case where the IDs are automatically generated by Jetspeed (like 
'P-108c087e90f-10001').

-- 
pozdrawiam,
     Jacek Wislicki

jacek.wislicki@gmail.com
tel.: +48 502 408 444
gg: 2540358
skype: jacek_wislicki

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


RE: Retrieving a portlet's unique instance ID..

Posted by Frank Villarreal <f_...@tetco.com>.
Ben,

Use the <init-param> tags in your portlet config file.  You can key off
these parameters to display a "different" initial view for each "instance"
of your portlet.  For example ....

    <init-param>
      <name>firstPage</name>
      <value>index.jsp</value>
    </init-param>

- Frank

> -----Original Message-----
> From: b.v.weert@valbosoft.com [mailto:b.v.weert@valbosoft.com]
> Sent: Monday, January 23, 2006 03:58 PM
> To: Jetspeed Users List
> Subject: Re: Retrieving a portlet's unique instance ID..
>
>
>
>
>
>
> Hello,
>
> we've developed some content management modules, which basically add a
> parameter to the portlet's definition called "channel" at
> creation time (so
> no further customization is required). At the same time we create that
> channel in the database. In this way, you can have a unique reference for
> the portlet without using the portlet ID.
> I think that what you're saying is that you use the same portlet for every
> content, while I'd create a new portlet for every appearance, so you can
> control every aspect at forehand.
>
> Regards,
>
> Bo van Weert
> tel. 902 014 180
> (00 34) 96 393 19 77
> fax. 96 360 69 13
> http://www.valbosoft.com: Jetspeed development
>
>
>
>
>
>
>              jetspeed@theunder
>
>              ground.net
>
>
>       To
>              23/01/2006 22:02          "Jetspeed Users List"
>
>
> <je...@portals.apache.org>
>
>       cc
>              Please respond to
>
>               "Jetspeed Users
>  Subject
>                    List"               Re: Retrieving a portlet's
> unique
>              <jetspeed-user@po         instance ID..
>
>              rtals.apache.org>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Thanks for the reply.  But I had a question about one of your points..
>
> > A portlet isn't really supposed to know about its 'unique id' as that is
> > an implementation detail of the portal.
>
> Perhaps the reason I encountered this problem is because I'm not thinking
> about the design in the correct way.  What are thoughts on the following
> situation:
>
> A generic Content Display Portlet (CDP) is to be created.  The requirement
> are that, whenever the CDP is added to a page, it will automatically
> create a new 'block' of content in the content management system that's
> associated to this individual CDP.
>
> The only way I can think of tackling that requirement would be for the
> portlet to be aware of some unique ID.  Then, in the render method (the
> first method to be executed), the portlet tries accessing the content
> repository with it's unique ID.  If the request fails, the portlet knows
> to create a new content object.  If the request succeeds, the portlet
> knows to display the content.  This 'unique key' could be done via portlet
> preferences, but then there would be an extra customizing step that would
> need to be performed after the portlet was added to a page (by the user
> clicking the Edit mode and then manually typing a unique string).
>
> Anyone out there have thoughts on this?  Am I thinking about this
> incorrectly, or is this a time when a portlet has a legitimate reason for
> fetching a unique identifier?
>
> -Ben
>
>
> >> Wiadomosc od jetspeed@theunderground.net z 2006-01-22 05:19 brzmiala:
> >>
> >>> Is there a way to get a portlet instance's unique ID without using the
> >>> request object (namely, from the portlet init() method)?
> >>
> >> As far as I know, init() is common for the whole portlet lifecycle (all
> >> instances) and is called at the webapp initialization (once for a
> >> restart/deployment), while the unique fragmend ID appears at each
> >> rendering the portlet (and it it constant as long as it is not changed
> >> in PSML).
> >>
> >> In order to get access to all fragments use ContentPage and
> >> ContentFragment implementations (getType() method to identify portlets)
> >> and recurse through your portal structure parsing each .psml file.
> >>
> > A portlet isn't really supposed to know about its 'unique id' as that is
> > an implementation detail of the portal.
> >
> > If you want to write portlets specific to Jetspeed-2, have a look at the
> > j2-admin app which accesses portal services in the jetspeed-portlet.xml
> >
> > <js:services>
> >          <js:service name='PageManager'/>
> >          <js:service name='PermissionManager'/>
> >          <js:service name='PortalAdministration'/>
> > ...
> > </js:services>
> >
> > ---------------------------------------------------------------------
> > 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
>
>
>
>
> ---------------------------------------------------------------------
> 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: Retrieving a portlet's unique instance ID..

Posted by b....@valbosoft.com.



Hello,

we've developed some content management modules, which basically add a
parameter to the portlet's definition called "channel" at creation time (so
no further customization is required). At the same time we create that
channel in the database. In this way, you can have a unique reference for
the portlet without using the portlet ID.
I think that what you're saying is that you use the same portlet for every
content, while I'd create a new portlet for every appearance, so you can
control every aspect at forehand.

Regards,

Bo van Weert
tel. 902 014 180
(00 34) 96 393 19 77
fax. 96 360 69 13
http://www.valbosoft.com: Jetspeed development




                                                                           
             jetspeed@theunder                                             
             ground.net                                                    
                                                                        To 
             23/01/2006 22:02          "Jetspeed Users List"               
                                       <je...@portals.apache.org>  
                                                                        cc 
             Please respond to                                             
              "Jetspeed Users                                      Subject 
                   List"               Re: Retrieving a portlet's unique   
             <jetspeed-user@po         instance ID..                       
             rtals.apache.org>                                             
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




Thanks for the reply.  But I had a question about one of your points..

> A portlet isn't really supposed to know about its 'unique id' as that is
> an implementation detail of the portal.

Perhaps the reason I encountered this problem is because I'm not thinking
about the design in the correct way.  What are thoughts on the following
situation:

A generic Content Display Portlet (CDP) is to be created.  The requirement
are that, whenever the CDP is added to a page, it will automatically
create a new 'block' of content in the content management system that's
associated to this individual CDP.

The only way I can think of tackling that requirement would be for the
portlet to be aware of some unique ID.  Then, in the render method (the
first method to be executed), the portlet tries accessing the content
repository with it's unique ID.  If the request fails, the portlet knows
to create a new content object.  If the request succeeds, the portlet
knows to display the content.  This 'unique key' could be done via portlet
preferences, but then there would be an extra customizing step that would
need to be performed after the portlet was added to a page (by the user
clicking the Edit mode and then manually typing a unique string).

Anyone out there have thoughts on this?  Am I thinking about this
incorrectly, or is this a time when a portlet has a legitimate reason for
fetching a unique identifier?

-Ben


>> Wiadomosc od jetspeed@theunderground.net z 2006-01-22 05:19 brzmiala:
>>
>>> Is there a way to get a portlet instance's unique ID without using the
>>> request object (namely, from the portlet init() method)?
>>
>> As far as I know, init() is common for the whole portlet lifecycle (all
>> instances) and is called at the webapp initialization (once for a
>> restart/deployment), while the unique fragmend ID appears at each
>> rendering the portlet (and it it constant as long as it is not changed
>> in PSML).
>>
>> In order to get access to all fragments use ContentPage and
>> ContentFragment implementations (getType() method to identify portlets)
>> and recurse through your portal structure parsing each .psml file.
>>
> A portlet isn't really supposed to know about its 'unique id' as that is
> an implementation detail of the portal.
>
> If you want to write portlets specific to Jetspeed-2, have a look at the
> j2-admin app which accesses portal services in the jetspeed-portlet.xml
>
> <js:services>
>          <js:service name='PageManager'/>
>          <js:service name='PermissionManager'/>
>          <js:service name='PortalAdministration'/>
> ...
> </js:services>
>
> ---------------------------------------------------------------------
> 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




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


Re: Retrieving a portlet's unique instance ID..

Posted by je...@theunderground.net.
Thanks for the reply.  But I had a question about one of your points..

> A portlet isn't really supposed to know about its 'unique id' as that is
> an implementation detail of the portal.

Perhaps the reason I encountered this problem is because I'm not thinking
about the design in the correct way.  What are thoughts on the following
situation:

A generic Content Display Portlet (CDP) is to be created.  The requirement
are that, whenever the CDP is added to a page, it will automatically
create a new 'block' of content in the content management system that's
associated to this individual CDP.

The only way I can think of tackling that requirement would be for the
portlet to be aware of some unique ID.  Then, in the render method (the
first method to be executed), the portlet tries accessing the content
repository with it's unique ID.  If the request fails, the portlet knows
to create a new content object.  If the request succeeds, the portlet
knows to display the content.  This 'unique key' could be done via portlet
preferences, but then there would be an extra customizing step that would
need to be performed after the portlet was added to a page (by the user
clicking the Edit mode and then manually typing a unique string).

Anyone out there have thoughts on this?  Am I thinking about this
incorrectly, or is this a time when a portlet has a legitimate reason for
fetching a unique identifier?

-Ben


>> Wiadomosc od jetspeed@theunderground.net z 2006-01-22 05:19 brzmiala:
>>
>>> Is there a way to get a portlet instance's unique ID without using the
>>> request object (namely, from the portlet init() method)?
>>
>> As far as I know, init() is common for the whole portlet lifecycle (all
>> instances) and is called at the webapp initialization (once for a
>> restart/deployment), while the unique fragmend ID appears at each
>> rendering the portlet (and it it constant as long as it is not changed
>> in PSML).
>>
>> In order to get access to all fragments use ContentPage and
>> ContentFragment implementations (getType() method to identify portlets)
>> and recurse through your portal structure parsing each .psml file.
>>
> A portlet isn't really supposed to know about its 'unique id' as that is
> an implementation detail of the portal.
>
> If you want to write portlets specific to Jetspeed-2, have a look at the
> j2-admin app which accesses portal services in the jetspeed-portlet.xml
>
> <js:services>
>          <js:service name='PageManager'/>
>          <js:service name='PermissionManager'/>
>          <js:service name='PortalAdministration'/>
> ...
> </js:services>
>
> ---------------------------------------------------------------------
> 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: Retrieving a portlet's unique instance ID..

Posted by Jacek Wiślicki <ja...@gmail.com>.
Wiadomosc od David Sean Taylor z 2006-01-26 00:15 brzmiala:

> Ate and I had a look at it.
> Appears that we are not checksumming the jetspeed-portlet.xml, but only 
> the portlet.xml to determine whether a registry changed occurred during 
> deployment. Until we decide on the best fix, a workaround would be to 
> modify the portlet.xml whenever you modify the jetspeed-portlet.xml
OK, now I see how it all works :)

-- 
pozdrawiam,
     Jacek Wislicki

jacek.wislicki@gmail.com
tel.: +48 502 408 444
gg: 2540358
skype: jacek_wislicki

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


Re: Retrieving a portlet's unique instance ID..

Posted by David Sean Taylor <da...@bluesunrise.com>.
Jacek Wiślicki wrote:

>>>> If you want to write portlets specific to Jetspeed-2, have a look at 
>>>> the j2-admin app which accesses portal services in the 
>>>> jetspeed-portlet.xml
>>>
>>> By the way, is the bug concerning service access fixed?
>>
>> You mean this one:
>> https://issues.apache.org/jira/browse/JS2-464
>> I'll try to get a look at it tonight
> 
> Thanks :)
> 
Ate and I had a look at it.
Appears that we are not checksumming the jetspeed-portlet.xml, but only 
the portlet.xml to determine whether a registry changed occurred during 
deployment. Until we decide on the best fix, a workaround would be to 
modify the portlet.xml whenever you modify the jetspeed-portlet.xml

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


Re: Retrieving a portlet's unique instance ID..

Posted by Jacek Wiślicki <ja...@gmail.com>.
Wiadomosc od David Sean Taylor z 2006-01-25 03:43 brzmiala:

>>> A portlet isn't really supposed to know about its 'unique id' as that 
>>> is an implementation detail of the portal.
>> However, when I managed to get the current fragment ID, I was able to 
>> create a universal portlet class whose behaviour, displayed contents 
>> and some security features are determined by some data stored in the 
>> database (fragment preferences were not enough for storing large 
>> amounts of data).
> What if you stored a unique key in the preference, say "content-id"
> This unique is portlet instance specific.
>  From there, you can map to your large amounts of data
But adding a preference is a manual process AFAIK and would require 
switching between different J2 admin applications when adding new 
fragments, not to mention possible human mistakes in typing the 
preference name, value and holding its uniqueness. Unless some 
modifications are done to portal mechanisms and the process becomes 
human-independent.

Furthermore, here the preference value would be just another unique ID 
(could have just the same value as the fragment ID). Is there a reason 
why you don't like such a solution other than portal and portlet logic 
assumptions?

>>> If you want to write portlets specific to Jetspeed-2, have a look at 
>>> the j2-admin app which accesses portal services in the 
>>> jetspeed-portlet.xml
>> By the way, is the bug concerning service access fixed?
> You mean this one:
> https://issues.apache.org/jira/browse/JS2-464
> I'll try to get a look at it tonight
Thanks :)

-- 
pozdrawiam,
     Jacek Wislicki

jacek.wislicki@gmail.com
tel.: +48 502 408 444
gg: 2540358
skype: jacek_wislicki

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


Re: Retrieving a portlet's unique instance ID..

Posted by David Sean Taylor <da...@bluesunrise.com>.
Jacek Wiślicki wrote:
> Wiadomosc od David Sean Taylor z 2006-01-23 09:50 brzmiala:
> 
>> A portlet isn't really supposed to know about its 'unique id' as that 
>> is an implementation detail of the portal.
> 
> However, when I managed to get the current fragment ID, I was able to 
> create a universal portlet class whose behaviour, displayed contents and 
> some security features are determined by some data stored in the 
> database (fragment preferences were not enough for storing large amounts 
> of data).

What if you stored a unique key in the preference, say "content-id"
This unique is portlet instance specific.
 From there, you can map to your large amounts of data

> 
>> If you want to write portlets specific to Jetspeed-2, have a look at 
>> the j2-admin app which accesses portal services in the 
>> jetspeed-portlet.xml
> 
> By the way, is the bug concerning service access fixed?
> 
You mean this one:

https://issues.apache.org/jira/browse/JS2-464

I'll try to get a look at it tonight


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


Re: Retrieving a portlet's unique instance ID..

Posted by Jacek Wiślicki <ja...@gmail.com>.
Wiadomosc od David Sean Taylor z 2006-01-23 09:50 brzmiala:

> A portlet isn't really supposed to know about its 'unique id' as that is 
> an implementation detail of the portal.
However, when I managed to get the current fragment ID, I was able to 
create a universal portlet class whose behaviour, displayed contents and 
some security features are determined by some data stored in the 
database (fragment preferences were not enough for storing large amounts 
of data).

> If you want to write portlets specific to Jetspeed-2, have a look at the 
> j2-admin app which accesses portal services in the jetspeed-portlet.xml
By the way, is the bug concerning service access fixed?

-- 
pozdrawiam,
     Jacek Wislicki

jacek.wislicki@gmail.com
tel.: +48 502 408 444
gg: 2540358
skype: jacek_wislicki

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


Re: Retrieving a portlet's unique instance ID..

Posted by David Sean Taylor <da...@bluesunrise.com>.
Jacek Wiślicki wrote:
> Wiadomosc od jetspeed@theunderground.net z 2006-01-22 05:19 brzmiala:
> 
>> Is there a way to get a portlet instance's unique ID without using the
>> request object (namely, from the portlet init() method)?
> 
> As far as I know, init() is common for the whole portlet lifecycle (all 
> instances) and is called at the webapp initialization (once for a 
> restart/deployment), while the unique fragmend ID appears at each 
> rendering the portlet (and it it constant as long as it is not changed 
> in PSML).
> 
> In order to get access to all fragments use ContentPage and 
> ContentFragment implementations (getType() method to identify portlets) 
> and recurse through your portal structure parsing each .psml file.
> 
A portlet isn't really supposed to know about its 'unique id' as that is 
an implementation detail of the portal.

If you want to write portlets specific to Jetspeed-2, have a look at the 
j2-admin app which accesses portal services in the jetspeed-portlet.xml

<js:services>
         <js:service name='PageManager'/>
         <js:service name='PermissionManager'/>
         <js:service name='PortalAdministration'/>
...
</js:services>

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


Re: Retrieving a portlet's unique instance ID..

Posted by Jacek Wiślicki <ja...@gmail.com>.
Wiadomosc od jetspeed@theunderground.net z 2006-01-22 05:19 brzmiala:

> Is there a way to get a portlet instance's unique ID without using the
> request object (namely, from the portlet init() method)?
As far as I know, init() is common for the whole portlet lifecycle (all 
instances) and is called at the webapp initialization (once for a 
restart/deployment), while the unique fragmend ID appears at each 
rendering the portlet (and it it constant as long as it is not changed 
in PSML).

In order to get access to all fragments use ContentPage and 
ContentFragment implementations (getType() method to identify portlets) 
and recurse through your portal structure parsing each .psml file.

-- 
pozdrawiam,
     Jacek Wislicki

jacek.wislicki@gmail.com
tel.: +48 502 408 444
gg: 2540358
skype: jacek_wislicki

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


Re: Retrieving a portlet's unique instance ID..

Posted by je...@theunderground.net.
Wow.. first off, you are a money dude for figuring that out.

However, the processes I need to run (that require a unique portlet
instance ID) are fairly resource-intensive and should only be run once
upon portlet initialization.  And, sadly, the init() method doesn't have
access to any type of request object from which to pull the fragment id.

Is there a way to get a portlet instance's unique ID without using the
request object (namely, from the portlet init() method)?

-Ben


> Wiadomosc od jetspeed@theunderground.net z 2006-01-22 02:26 brzmiala:
>
>> All,
>>
>> Okay, so I have a portal that will have multiple instances of my content
>> display portlet.  But each instance of my portlet needs to have a way of
>> retrieving some ID that differentiates it from all the other, identical
>> content display portlets.  This ID should not only be unique to this
>> portlet instance, but also persistant across server restarts.
>>
>> Is this possible in Jetspeed 2?
> I've done a similar task yesterday :) In order to get fragment's
> identifier (like the one in PSML file) use something like this:
> ((ContentFragment)request.getAttribute(PortalReservedParameters.FRAGMENT_ATTRIBUTE)).getId();
> where request is RenderRequest.
>
> --
> pozdrawiam,
>      Jacek Wislicki
>
> jacek.wislicki@gmail.com
> tel.: +48 502 408 444
> gg: 2540358
> skype: jacek_wislicki
>
> ---------------------------------------------------------------------
> 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: Retrieving a portlet's unique instance ID..

Posted by Jacek Wiślicki <ja...@gmail.com>.
Wiadomosc od jetspeed@theunderground.net z 2006-01-22 02:26 brzmiala:

> All,
> 
> Okay, so I have a portal that will have multiple instances of my content
> display portlet.  But each instance of my portlet needs to have a way of
> retrieving some ID that differentiates it from all the other, identical
> content display portlets.  This ID should not only be unique to this
> portlet instance, but also persistant across server restarts.
> 
> Is this possible in Jetspeed 2?
I've done a similar task yesterday :) In order to get fragment's 
identifier (like the one in PSML file) use something like this:
((ContentFragment)request.getAttribute(PortalReservedParameters.FRAGMENT_ATTRIBUTE)).getId();
where request is RenderRequest.

-- 
pozdrawiam,
     Jacek Wislicki

jacek.wislicki@gmail.com
tel.: +48 502 408 444
gg: 2540358
skype: jacek_wislicki

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