org.opencms.jsp
Class CmsJspNavBuilder

java.lang.Object
  extended by org.opencms.jsp.CmsJspNavBuilder

public class CmsJspNavBuilder
extends java.lang.Object

Bean to provide a convenient way to build navigation structures based on the CmsJspNavElement.

Use this together with the CmsJspActionElement to obtain navigation information based on the current users permissions. For example, use getNavigationForFolder(String) and pass the value of the current OpenCms user context uri obtained from CmsRequestContext.getUri() as argument to obtain a list of all items in the navigation of the current folder. Then use a simple scriptlet to iterate over these items and create a HTML navigation.

Since:
6.0.0
Version:
$Revision: 1.28 $
Author:
Alexander Kandzior
See Also:
CmsJspNavElement

Constructor Summary
CmsJspNavBuilder()
          Empty constructor, so that this bean can be initialized from a JSP.
CmsJspNavBuilder(CmsObject cms)
          Default constructor.
 
Method Summary
static java.lang.String getDefaultFile(CmsObject cms, java.lang.String folder)
          Returns the full name (including vfs path) of the default file for this nav element or null if the nav element is not a folder.
 java.util.List getNavigationBreadCrumb()
          Build a "bread crump" path navigation to the current folder.
 java.util.List getNavigationBreadCrumb(int startlevel, boolean currentFolder)
          Build a "bread crump" path navigation to the current folder.
 java.util.List getNavigationBreadCrumb(int startlevel, int endlevel)
          Build a "bread crump" path navigation to the current folder.
 java.util.List getNavigationBreadCrumb(java.lang.String folder, int startlevel, int endlevel, boolean currentFolder)
          Build a "bread crump" path navigation to the given folder.
 java.util.List getNavigationForFolder()
          Collect all navigation elements from the files of the folder of the current request URI, navigation elements are of class CmsJspNavElement.
static java.util.List getNavigationForFolder(CmsObject cms, java.lang.String folder)
          Collect all navigation elements from the files in the given folder, navigation elements are of class CmsJspNavElement.
static java.util.List getNavigationForFolder(CmsObject cms, java.lang.String folder, int level)
          Build a navigation for the folder that is either minus levels up from the given folder, or that is plus levels down from the root folder towards the given folder.
 java.util.List getNavigationForFolder(int level)
          Build a navigation for the folder that is either minus levels up from of the folder of the current request URI, or that is plus levels down from the root folder towards the current request URI.
 java.util.List getNavigationForFolder(java.lang.String folder)
          Collect all navigation elements from the files in the given folder, navigation elements are of class CmsJspNavElement.
 java.util.List getNavigationForFolder(java.lang.String folder, int level)
          Build a navigation for the folder that is either minus levels up from the given folder, or that is plus levels down from the root folder towards the given folder.
 CmsJspNavElement getNavigationForResource()
          Returns a CmsJspNavElement for the resource of the current request URI.
static CmsJspNavElement getNavigationForResource(CmsObject cms, java.lang.String resource)
          Returns a CmsJspNavElement for the named resource.
 CmsJspNavElement getNavigationForResource(java.lang.String resource)
          Returns a CmsJspNavElement for the named resource.
static java.util.List getNavigationTreeForFolder(CmsObject cms, java.lang.String folder, int startlevel, int endlevel)
          Builds a tree navigation for the folders between the provided start and end level.
 java.util.List getNavigationTreeForFolder(int startlevel, int endlevel)
          Builds a tree navigation for the folders between the provided start and end level.
 java.util.List getNavigationTreeForFolder(java.lang.String folder, int startlevel, int endlevel)
          Builds a tree navigation for the folders between the provided start and end level.
 java.util.List getSiteNavigation()
          This method builds a complete site navigation tree with entries of all branches.
static java.util.List getSiteNavigation(CmsObject cms, java.lang.String folder, int endLevel)
          This method builds a complete navigation tree with entries of all branches from the specified folder.
 java.util.List getSiteNavigation(java.lang.String folder, int endLevel)
          This method builds a complete navigation tree with entries of all branches from the specified folder.
 void init(CmsObject cms)
          Initiliazes this bean.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CmsJspNavBuilder

public CmsJspNavBuilder()
Empty constructor, so that this bean can be initialized from a JSP.

See Also:
Object.Object()

CmsJspNavBuilder

public CmsJspNavBuilder(CmsObject cms)
Default constructor.

Parameters:
cms - context provider for the current request
Method Detail

getDefaultFile

public static java.lang.String getDefaultFile(CmsObject cms,
                                              java.lang.String folder)
Returns the full name (including vfs path) of the default file for this nav element or null if the nav element is not a folder.

The default file of a folder is determined by the value of the property default-file or the systemwide property setting.

Parameters:
cms - the cms object
folder - full name of the folder
Returns:
the name of the default file

getNavigationForFolder

public static java.util.List getNavigationForFolder(CmsObject cms,
                                                    java.lang.String folder)
Collect all navigation elements from the files in the given folder, navigation elements are of class CmsJspNavElement.

Parameters:
cms - context provider for the current request
folder - the selected folder
Returns:
a sorted (ascending to nav position) ArrayList of navigation elements

getNavigationForFolder

public static java.util.List getNavigationForFolder(CmsObject cms,
                                                    java.lang.String folder,
                                                    int level)
Build a navigation for the folder that is either minus levels up from the given folder, or that is plus levels down from the root folder towards the given folder.

If level is set to zero the root folder is used by convention.

Parameters:
cms - context provider for the current request
folder - the selected folder
level - if negative, walk this many levels up, if positive, walk this many levels down from root folder
Returns:
a sorted (ascending to nav position) ArrayList of navigation elements

getNavigationForResource

public static CmsJspNavElement getNavigationForResource(CmsObject cms,
                                                        java.lang.String resource)
Returns a CmsJspNavElement for the named resource.

Parameters:
cms - context provider for the current request
resource - the resource name to get the nav information for, must be a full path name, e.g. "/docs/index.html".
Returns:
a CmsJspNavElement for the given resource

getNavigationTreeForFolder

public static java.util.List getNavigationTreeForFolder(CmsObject cms,
                                                        java.lang.String folder,
                                                        int startlevel,
                                                        int endlevel)
Builds a tree navigation for the folders between the provided start and end level.

A tree navigation includes all nav elements that are required to display a tree structure. However, the data structure is a simple list. Each of the nav elements in the list has the CmsJspNavElement.getNavTreeLevel() set to the level it belongs to. Use this information to distinguish between the nav levels.

Parameters:
cms - context provider for the current request
folder - the selected folder
startlevel - the start level
endlevel - the end level
Returns:
a sorted list of nav elements with the nav tree level property set

getSiteNavigation

public static java.util.List getSiteNavigation(CmsObject cms,
                                               java.lang.String folder,
                                               int endLevel)
This method builds a complete navigation tree with entries of all branches from the specified folder.

For an unlimited depth of the navigation (i.e. no endLevel), set the endLevel to a value < 0.

Parameters:
cms - the current CmsJspActionElement.
folder - the root folder of the navigation tree.
endLevel - the end level of the navigation.
Returns:
ArrayList of CmsJspNavElement, in depth first order.

getNavigationBreadCrumb

public java.util.List getNavigationBreadCrumb()
Build a "bread crump" path navigation to the current folder.

Returns:
ArrayList sorted list of navigation elements
See Also:
getNavigationBreadCrumb(String, int, int, boolean)

getNavigationBreadCrumb

public java.util.List getNavigationBreadCrumb(int startlevel,
                                              boolean currentFolder)
Build a "bread crump" path navigation to the current folder.

Parameters:
startlevel - the start level, if negative, go down |n| steps from selected folder
currentFolder - include the selected folder in navigation or not
Returns:
ArrayList sorted list of navigation elements
See Also:
getNavigationBreadCrumb(String, int, int, boolean)

getNavigationBreadCrumb

public java.util.List getNavigationBreadCrumb(int startlevel,
                                              int endlevel)
Build a "bread crump" path navigation to the current folder.

Parameters:
startlevel - the start level, if negative, go down |n| steps from selected folder
endlevel - the end level, if -1, build navigation to selected folder
Returns:
ArrayList sorted list of navigation elements
See Also:
getNavigationBreadCrumb(String, int, int, boolean)

getNavigationBreadCrumb

public java.util.List getNavigationBreadCrumb(java.lang.String folder,
                                              int startlevel,
                                              int endlevel,
                                              boolean currentFolder)
Build a "bread crump" path navigation to the given folder.

The startlevel marks the point where the navigation starts from, if negative, the count of steps to go down from the given folder. The endlevel is the maximum level of the navigation path, set it to -1 to build the complete navigation to the given folder. You can include the given folder in the navigation by setting currentFolder to true, otherwise false.

Parameters:
folder - the selected folder
startlevel - the start level, if negative, go down |n| steps from selected folder
endlevel - the end level, if -1, build navigation to selected folder
currentFolder - include the selected folder in navigation or not
Returns:
ArrayList sorted list of navigation elements

getNavigationForFolder

public java.util.List getNavigationForFolder()
Collect all navigation elements from the files of the folder of the current request URI, navigation elements are of class CmsJspNavElement.

Returns:
a sorted (ascending to nav position) ArrayList of navigation elements.

getNavigationForFolder

public java.util.List getNavigationForFolder(int level)
Build a navigation for the folder that is either minus levels up from of the folder of the current request URI, or that is plus levels down from the root folder towards the current request URI.

If level is set to zero the root folder is used by convention.

Parameters:
level - if negative, walk this many levels up, if positive, walk this many levels down from root folder
Returns:
a sorted (ascending to nav position) ArrayList of navigation elements

getNavigationForFolder

public java.util.List getNavigationForFolder(java.lang.String folder)
Collect all navigation elements from the files in the given folder, navigation elements are of class CmsJspNavElement.

Parameters:
folder - the selected folder
Returns:
A sorted (ascending to nav position) ArrayList of navigation elements.

getNavigationForFolder

public java.util.List getNavigationForFolder(java.lang.String folder,
                                             int level)
Build a navigation for the folder that is either minus levels up from the given folder, or that is plus levels down from the root folder towards the given folder.

If level is set to zero the root folder is used by convention.

Parameters:
folder - the selected folder
level - if negative, walk this many levels up, if positive, walk this many levels down from root folder
Returns:
a sorted (ascending to nav position) ArrayList of navigation elements

getNavigationForResource

public CmsJspNavElement getNavigationForResource()
Returns a CmsJspNavElement for the resource of the current request URI.

Returns:
CmsJspNavElement a CmsJspNavElement for the resource of the current request URI

getNavigationForResource

public CmsJspNavElement getNavigationForResource(java.lang.String resource)
Returns a CmsJspNavElement for the named resource.

Parameters:
resource - the resource name to get the nav information for, must be a full path name, e.g. "/docs/index.html".
Returns:
CmsJspNavElement a CmsJspNavElement for the given resource

getNavigationTreeForFolder

public java.util.List getNavigationTreeForFolder(int startlevel,
                                                 int endlevel)
Builds a tree navigation for the folders between the provided start and end level.

Parameters:
startlevel - the start level
endlevel - the end level
Returns:
a sorted list of nav elements with the nav tree level property set
See Also:
getNavigationTreeForFolder(CmsObject, String, int, int)

getNavigationTreeForFolder

public java.util.List getNavigationTreeForFolder(java.lang.String folder,
                                                 int startlevel,
                                                 int endlevel)
Builds a tree navigation for the folders between the provided start and end level.

Parameters:
folder - the selected folder
startlevel - the start level
endlevel - the end level
Returns:
a sorted list of nav elements with the nav tree level property set
See Also:
getNavigationTreeForFolder(CmsObject, String, int, int)

getSiteNavigation

public java.util.List getSiteNavigation()
This method builds a complete site navigation tree with entries of all branches.

Returns:
ArrayList of CmsJspNavElement, in depth first order.
See Also:
getSiteNavigation(CmsObject, String, int)

getSiteNavigation

public java.util.List getSiteNavigation(java.lang.String folder,
                                        int endLevel)
This method builds a complete navigation tree with entries of all branches from the specified folder.

Parameters:
folder - folder the root folder of the navigation tree.
endLevel - the end level of the navigation.
Returns:
ArrayList of CmsJspNavElement, in depth first order.
See Also:
getSiteNavigation(CmsObject, String, int)

init

public void init(CmsObject cms)
Initiliazes this bean.

Parameters:
cms - context provider for the current request