[opencms-dev] <cms:contentload>-tag and no collector results

Dave Schoorl maillists at cyber-d.com
Mon Aug 21 16:53:41 CEST 2006


Hi list,

I am new to OpenCms and I am using version 6.2.2. I have a problem with 
the cms:contentload-tag. When the collector finds no matching resources, 
I receive a null-pointer exception. A snippet of my jsp is as follows:

<cms:contentload collector="myCollector"
      param="${opencms.uri}|myResourceType" editable="true">

   <cms:contentloop element="Paragraph">
     <span class="par" title="Paragraph">
       <cms:contentcheck ifexists="Title">
         <h1><cms:contentshow element="Title" /></h1>
       </cms:contentcheck>
     </span>
   </cms:contentloop>

    ... looping through other elementtypes ...

</cms:contentload>

When I look in the source code, I see at the end of the doStartTag in 
CmsJspTagContentLoad the following (this is also the case in CVS HEAD):

   // initialize the content load tag
   init(container);
   hasMoreContent();
   return EVAL_BODY_INCLUDE;

So, the body is included even when there is no content. Is it not better 
to change this to:

   // initialize the content load tag
   init(container);
   if (hasMoreContent() == true) {
     return EVAL_BODY_INCLUDE;
   } else {
     return SKIP_BODY;
   }

I think this will be more appropriate. Or am I missing something?

Kind regards,

Dave




More information about the opencms-dev mailing list