public class CmsJspNavBuilder extends java.lang.Object
CmsJspNavElement
.
Use this together with the
to obtain navigation information based on the current users permissions.
For example, use CmsJspActionElement
and pass the
value of the current OpenCms user context uri obtained
from getNavigationForFolder(String)
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.CmsRequestContext.getUri()
CmsJspNavElement
Modifier and Type | Class and Description |
---|---|
static class |
CmsJspNavBuilder.Visibility
The visibility mode.
|
Modifier and Type | Field and Description |
---|---|
protected CmsObject |
m_cms
The current CMS context.
|
protected java.lang.String |
m_requestUri
The current request URI.
|
protected java.lang.String |
m_requestUriFolder
The current request folder.
|
static java.lang.String |
NAVIGATION_LEVEL_FOLDER
Default file property value to mark navigation level folders.
|
Constructor and Description |
---|
CmsJspNavBuilder()
Empty constructor, so that this bean can be initialized from a JSP.
|
CmsJspNavBuilder(CmsObject cms)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
java.util.List<CmsJspNavElement> |
getNavigationBreadCrumb()
Build a "bread crumb" path navigation to the current folder.
|
java.util.List<CmsJspNavElement> |
getNavigationBreadCrumb(int startlevel,
boolean currentFolder)
Build a "bread crumb" path navigation to the current folder.
|
java.util.List<CmsJspNavElement> |
getNavigationBreadCrumb(int startlevel,
int endlevel)
Build a "bread crumb" path navigation to the current folder.
|
java.util.List<CmsJspNavElement> |
getNavigationBreadCrumb(java.lang.String folder,
int startlevel,
int endlevel,
boolean currentFolder)
Build a "bread crumb" path navigation to the given folder.
|
java.util.List<CmsJspNavElement> |
getNavigationForFolder()
Collect all navigation elements from the files of the folder of the current request URI.
|
java.util.List<CmsJspNavElement> |
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<CmsJspNavElement> |
getNavigationForFolder(java.lang.String folder)
Collect all navigation visible elements from the files in the given folder.
|
java.util.List<CmsJspNavElement> |
getNavigationForFolder(java.lang.String folder,
CmsJspNavBuilder.Visibility visibility,
CmsResourceFilter resourceFilter)
Collect all navigation elements from the files in the given folder.
|
java.util.List<CmsJspNavElement> |
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 navigation element for the resource of the current request URI.
|
CmsJspNavElement |
getNavigationForResource(java.lang.String sitePath)
Returns a navigation element for the named resource.
|
CmsJspNavElement |
getNavigationForResource(java.lang.String sitePath,
CmsResourceFilter reourceFilter)
Returns a navigation element for the named resource.
|
java.util.List<CmsJspNavElement> |
getNavigationTreeForFolder(int startlevel,
int endlevel)
Builds a tree navigation for the folders between the provided start and end level.
|
java.util.List<CmsJspNavElement> |
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<CmsJspNavElement> |
getSiteNavigation()
This method builds a complete site navigation tree with entries of all branches.
|
java.util.List<CmsJspNavElement> |
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)
Initializes this bean.
|
static boolean |
isNavLevelFolder(CmsObject cms,
CmsResource resource)
Returns whether the given resource is a folder and is marked to be a navigation level folder.
|
protected java.lang.String m_requestUri
protected java.lang.String m_requestUriFolder
public static final java.lang.String NAVIGATION_LEVEL_FOLDER
public CmsJspNavBuilder()
public CmsJspNavBuilder(CmsObject cms)
cms
- context provider for the current requestpublic java.util.List<CmsJspNavElement> getNavigationBreadCrumb()
getNavigationBreadCrumb(String, int, int, boolean)
public java.util.List<CmsJspNavElement> getNavigationBreadCrumb(int startlevel, boolean currentFolder)
startlevel
- the start level, if negative, go down |n| steps from selected foldercurrentFolder
- include the selected folder in navigation or notgetNavigationBreadCrumb(String, int, int, boolean)
public java.util.List<CmsJspNavElement> getNavigationBreadCrumb(int startlevel, int endlevel)
startlevel
- the start level, if negative, go down |n| steps from selected folderendlevel
- the end level, if -1, build navigation to selected foldergetNavigationBreadCrumb(String, int, int, boolean)
public java.util.List<CmsJspNavElement> getNavigationBreadCrumb(java.lang.String folder, int startlevel, int endlevel, boolean currentFolder)
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
.
folder
- the selected folderstartlevel
- the start level, if negative, go down |n| steps from selected folderendlevel
- the end level, if -1, build navigation to selected foldercurrentFolder
- include the selected folder in navigation or notpublic java.util.List<CmsJspNavElement> getNavigationForFolder()
public java.util.List<CmsJspNavElement> getNavigationForFolder(int level)
If level is set to zero the root folder is used by convention.
level
- if negative, walk this many levels up, if positive, walk this many
levels down from root folderpublic java.util.List<CmsJspNavElement> getNavigationForFolder(java.lang.String folder)
folder
- the selected folderpublic java.util.List<CmsJspNavElement> getNavigationForFolder(java.lang.String folder, CmsJspNavBuilder.Visibility visibility, CmsResourceFilter resourceFilter)
folder
- the selected foldervisibility
- the visibility moderesourceFilter
- the filter to use reading the resourcespublic java.util.List<CmsJspNavElement> getNavigationForFolder(java.lang.String folder, int level)
If level is set to zero the root folder is used by convention.
folder
- the selected folderlevel
- if negative, walk this many levels up, if positive, walk this many
levels down from root folderpublic CmsJspNavElement getNavigationForResource()
public CmsJspNavElement getNavigationForResource(java.lang.String sitePath)
sitePath
- the resource name to get the navigation information for,
must be a full path name, e.g. "/docs/index.html"public CmsJspNavElement getNavigationForResource(java.lang.String sitePath, CmsResourceFilter reourceFilter)
sitePath
- the resource name to get the navigation information for,
must be a full path name, e.g. "/docs/index.html"reourceFilter
- the resource filterpublic java.util.List<CmsJspNavElement> getNavigationTreeForFolder(int startlevel, int endlevel)
startlevel
- the start levelendlevel
- the end levelgetNavigationTreeForFolder(String, int, int)
public java.util.List<CmsJspNavElement> getNavigationTreeForFolder(java.lang.String folder, int startlevel, int endlevel)
folder
- the selected folderstartlevel
- the start levelendlevel
- the end levelpublic java.util.List<CmsJspNavElement> getSiteNavigation()
getSiteNavigation(String, int)
public java.util.List<CmsJspNavElement> getSiteNavigation(java.lang.String folder, int endLevel)
folder
- folder the root folder of the navigation treeendLevel
- the end level of the navigationpublic void init(CmsObject cms)
cms
- the current cms contextpublic static boolean isNavLevelFolder(CmsObject cms, CmsResource resource)
cms
- the cms contextresource
- the resourcetrue
if the resource is marked to be a navigation level folder