David,

Tried your code but kept getting nullpointerexceptions on

Portlets portlets = profile.getDocument().getPortlets();

I'm attempting to write a jsp whereby a drop down list is presented to the
user populated with portlets that they can then change the source URL of.
Bit like a favourites page.

Jetspeed is proving to try it's best to stop me from achieving this, well
probably more like my inability to follow the way thruogh the code !!!

Any further assistance appreciated.

Jon Hawkins


> Jonathan Hawkins wrote:
>
>>
>> I want to get a list of the portlets by name or id that are in the
>> users profile, not a list of available portlets but only those that
>> are currently configured in the portal for that user.
>>
>> Any assistance appreciated.
>
> Try somethin like this:
>
>     public void doPerform(RunData data) throws Exception
>     {
>         Profile profile = ((JetspeedRunData)
>         data).getCustomizedProfile(); Portlets portlets =
>         profile.getDocument().getPortlets();
>         if (portlets == null)
>         {
>             return;
>         }
>         int count = 0;
>         count = traverse(portlets, count);
>         super.doPerform(data);
>
>     }
>
>     private int traverse(Portlets portlets, int count)
>     {
>         // First let's add all the Entries in the current level
>         Iterator eItr = portlets.getEntriesIterator();
>         while(eItr.hasNext())
>         {
>             Entry entry =  (Entry)eItr.next();
>
>             Portlet portlet = null;
>             try
>             {
>                 portlet = PortletFactory.getPortlet(entry);
>             }
>             catch (Exception e)
>             {
>                 log.error("Could not create portlet for entry " +
> entry.getId(), e);
>                 continue;
>             }
>             if (portlet == null)
>             {
>                 log.error("Could not create portlet for entry " +
> entry.getId());
>                 continue;
>             }
>       }
>         //Now if there are child levels, drill down recursively
>         if(portlets.getPortletsCount() > 0)
>         {
>             Iterator pItr = portlets.getPortletsIterator();
>             while(pItr.hasNext())
>             {
>                 Portlets childPortlets = (Portlets)pItr.next();
>                 count += traverse(childPortlets, count);
>             }
>         }
>         return count;
>     }
>
> --
> David Sean Taylor
> Bluesunrise Software
> [EMAIL PROTECTED]
> [office] +01 707 773 4646
> [mobile] +01 707 529 9194
>
> ---------------------------------------------------------------------
> 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]

Reply via email to