[opencms-dev] Issue with getNavigationForFolder
Nicolas Delsaux
nicolas.delsaux at online.fr
Fri Jun 13 14:55:02 CEST 2003
Hi all,
Yes, I know I may be quite dumb using OpenCMS. But one more time, I'm
facing a strange issue.
In my recursive method (already discussed), I use ArrayList files =
cms.getNavigation().getNavigationForFolder(uri); (where URI is
cms.getRequestContext().getUri();) to get all the files in a directory.
And unfortunatly, I get all my site hierarchy. Of course, it gives me an
easy site map, but it's obviously not what I want. In fact, I would prefer
to see getNavigationForFolder behave as expected.
I've removed the recursive part, and the list I get is the root list.
Can someone explain me why I have this strange issue ?
Here is the full jsp code.
<%@ page session="false"
import="com.opencms.flex.jsp.*,com.opencms.file.*,java.util.*" %><%--
Linagora
--%>
<%!
public void listFilesAndFolders(java.io.Writer out,
com.opencms.flex.jsp.CmsJspActionElement cms, String uri, boolean
recursive) throws Exception {
String desc;
out.write("<!-- "+uri+" -->\n");
ArrayList files = cms.getNavigation().getNavigationForFolder(uri);
if(files.size() > 0) {
out.write("<ul class=\"list-files\">\n");
Iterator iter = files.iterator();
CmsJspNavElement nav;
String target;
while(iter.hasNext()) {
nav = (CmsJspNavElement) iter.next();
if(nav!=null) {
target = nav.getResourceName();
out.write("\t<li class=\"list-files\">");
if(nav.isFolderLink()) {
target = cms.link(target + "index.jsp");
} else { // else if folderLink
target = cms.link(target);
} // end if folderLink
out.write("<!-- "+nav.getResourceName()+" --><a class=\"list-files\"
href=\""+target+"\">"+nav.getNavText()+"</a>\n");
desc = nav.getDescription();
if(desc!=null) out.write(" "+desc);
if(nav.isFolderLink() && recursive) {
// listFilesAndFolders(out, cms, nav.getResourceName(), recursive);
}
} // end if nav!=null
} // end while
out.write("</ul>\n");
} // end if size>0 } // end method %>
<% com.opencms.flex.jsp.CmsJspActionElement cms = new
com.opencms.flex.jsp.CmsJspActionElement(pageContext, request, response);
String uri = cms.getRequestContext().getUri();
uri = uri.substring(0, uri.lastIndexOf("/"));
listFilesAndFolders(out, cms, uri, true);
%>
It is used in the destination jsp the following way :
<%@ page session="false"
import="com.opencms.flex.jsp.*,java.lang.*,java.util.*,com.opencms.flex.util.CmsMessages"
%>
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
<cms:include property="template" suffix=".jsp" element="head" />
<cms:include page="/system/modules/com.linagora.open-
j2ee/elements/recursive_lister.jsp"/>
<cms:include property="template" suffix=".jsp" element="foot" />
More information about the opencms-dev
mailing list