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 Balaji Chandrasekaran <cb...@virtusa.com> on 2006/05/02 17:38:11 UTC

getting no of fragments

Hi all....

In the doView I want to get the no of fragments available in the psml
file for which the portlet class is getting executed...how I do
that...Pls respond ASAP.

 

Thanks in advance.

 

 

Regards,

Balaji C


Re: getting no of fragments

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

>     protected List listFragments(Fragment rootFragment, String type, 
> List list)
>     {
>         List fragments = rootFragment.getFragments();
>         for(Iterator iterator = fragments.iterator(); iterator.hasNext();)
>         {
>             Fragment fragment = (Fragment)iterator.next();
>             if(fragment.getType().equals(Fragment.PORTLET))
>                 list.add(fragment);
>            
>             listFragments(fragment, type, list);
>         }
>        
>         return list;
>     }
> This list all fragments, not only portlet fragments, contained within a 
> "rootFragment".
Oops, it *does* list only portlet fragments :)

-- 
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: getting no of fragments

Posted by Jacek Wiślicki <ja...@gmail.com>.
Wiadomosc od Balaji Chandrasekaran z 2006-05-02 17:38 brzmiala:

> In the doView I want to get the no of fragments available in the psml
> file for which the portlet class is getting executed...how I do
> that...Pls respond ASAP.
Something like this works for me:
	protected List listFragments(Fragment rootFragment, String type, List list)
	{
		List fragments = rootFragment.getFragments();
		for(Iterator iterator = fragments.iterator(); iterator.hasNext();)
		{
			Fragment fragment = (Fragment)iterator.next();
			if(fragment.getType().equals(Fragment.PORTLET))
				list.add(fragment);
			
			listFragments(fragment, type, list);
		}
		
		return list;
	}
This list all fragments, not only portlet fragments, contained within a 
"rootFragment".

In order to get all PSML pages, use the methid like:
	public List listAllNodes(String path, String type, List list)
	{
		if(!path.endsWith("/"))
			path = path + "/";
		Folder folder = getFolder(path);
		
		Iterator iter;
		NodeSet nodes = null;

		try
		{
			if(type.equals(Folder.FOLDER_TYPE))
				nodes = folder.getFolders();
			else if(type.equals(Page.DOCUMENT_TYPE))
				nodes = folder.getPages();
			else if(type.equals(Link.DOCUMENT_TYPE))
				nodes = folder.getLinks();

			iter = nodes.iterator();
			while(iter.hasNext())
				list.add(iter.next());
		}
		catch(FolderNotFoundException exc)
		{
			logger.debug(exc);
		}
		catch(DocumentException exc)
		{
			logger.debug(exc);
		}
		catch(NodeException exc)
		{
			logger.debug(exc);
		}
		
		try
		{
			nodes = folder.getFolders();
			iter = nodes.iterator();
			while(iter.hasNext())
				listAllNodes(((Folder)iter.next()).getPath(), type, list);
		}
		catch(FolderNotFoundException exc)
		{
			logger.debug(exc);
		}
		catch(DocumentException exc)
		{
			logger.debug(exc);
		}
		
		return list;
	}
where a "type" would be "Page.DOCUMENT_TYPE" and a "path" equal to the 
root folder "/".

For each page returned from the method get its root fragment and aply 
the first method supplied above.

-- 
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