[opencms-dev] problem with jsp template

Fabian Fabian18 at firemail.de
Thu Nov 6 09:31:00 CET 2003


Hi,

I found this code and integrated it in an jsp template. I want to check wether an part of an multiple content 
page is empty or not. The problem is it doesn't work. I haven't any experience in jsp. Can someone tell me 
what's wrong?
Without the function and the function call the body part is displayed.

Here's my code:

<%@ page session="false" %>
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
<% 
  com.opencms.flex.jsp.CmsJspActionElement cms1 = new com.opencms.flex.jsp.CmsJspActionElement
(pageContext, request, response);
  String pageName = cms1.info("opencms.request.uri");
%>

<%! 
  boolean hasContent(com.opencms.flex.jsp.CmsJspActionElement c, String pn, String element) { 
    boolean b = false; 

    try { 
      pn = "/system/bodies" + pn; 
      element = "<edittemplate name=\"" + element + "\"><![CDATA["; 

      CmsFile file = c.getCmsObject().readFile( pn ); 
      String fileResult = new String(file.getContents()); 
      String sAnswer = " "; 

      int el = fileResult.indexOf( element ); 
      if ( el > 0 ) { 
        sAnswer = fileResult.substring( (el+element.length()), fileResult.length() ); 
      } 
      if (sAnswer.indexOf("]]></edittemplate>") > 1 ) { 
        b = true; 
      } 
      return b; 
    } 
    catch (Exception e) { 
      return b; 
    } 
  } 
%> 

<table width="100%" border="0">
  <tr>
    <td>
      <%-- if ( hasContent(cms1, pageName, "body") ) { %> 
        <cms:template element="body" > 
        <cms:include element="body" /> 
        </cms:template> 
      <% }; --%> 
    </td>
  </tr>
</table>

_________________________________________________________________
www.ebay.de Hier Finden Sie Auktionen und Festpreisangebote!





More information about the opencms-dev mailing list