[opencms-dev] nullpointer exception while using contentload on empty folder

René Machel rene.machel at unitb.de
Thu Feb 23 11:44:56 CET 2006


try catch isnt the best solution for this problem so i searched and came to
this, check the code:

<%@page buffer="none" session="false" import="java.util.*,
org.opencms.file.*, org.opencms.file.collectors.*, org.opencms.main.*,
org.opencms.jsp.CmsJspActionElement" %>
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
<%

// initialize action element to access the API
CmsTemplateBean cms = new CmsTemplateBean(pageContext, request,
response);CmsJspActionElement cms2 = new CmsJspActionElement(pageContext,
request, response); 

CmsObject cms_o = cms.getCmsObject();

// get the current folder
String reqPath = cms.info("opencms.request.folder");

String collName = "allInFolder";

I_CmsResourceCollector coll =
OpenCms.getResourceManager().getContentCollector(collName);
List list = coll.getResults(cms2.getCmsObject(),
collName,(reqPath+"|maske_teaser"));

   if(list != null && list.size() > 0) {
%> 

<cms:contentload collector="allInFolder"
param="${opencms.folder}teaser_${number}|teaser" editable="true">
   do sumtin
</cms:contentload>

<%
}
%>

this solved the problem instantly and no "ghost" xmlcontent boxes appeared
--
View this message in context: http://www.nabble.com/nullpointer-exception-while-using-contentload-on-empty-folder-t1162862.html#a3087058
Sent from the OpenCMS - Dev forum at Nabble.com.




More information about the opencms-dev mailing list