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

René Machel rene.machel at unitb.de
Thu Feb 23 11:48:38 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+"|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





René Machel wrote:
> 
> hi list,
> 
> how can i check if there is xmlContent in my current folder without 
> OpenCms throwing a nullpointer exception if there is nothing to load (no 
> teaser in that folder) ?
> my contentload jsp file  looks like this:
> 
> <cms:contentload collector="allInFolderDateReleasedDesc" 
> param="${opencms.folder}teaser_${number}|teaser" editable="true">
>     do somethin
> </cms:contentload>
> 
> 
> thx in advance
> 
> rené
> 
> 
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev
> 
> 
--
View this message in context: http://www.nabble.com/nullpointer-exception-while-using-contentload-on-empty-folder-t1162862.html#a3087112
Sent from the OpenCMS - Dev forum at Nabble.com.




More information about the opencms-dev mailing list