Re: Jahia 6 Community Edition - size of a containerList populated by a query

Jahia papez <[email protected]> Tue, 17 Feb 2009 22:48:42 +0100
Newsgroups gmane.comp.cms.jahia.template
Message-ID <[email protected]>
--===============1658634768==
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Mesdocs,<br>
<br>
I think the problem in your code is that the name="actusContainer"
attribute is missing in the &lt;template:containerList&gt; tag. I think
that "name" should be set as a required attribute. Please try it and
let me know, if it worked.<br>
<br>
Regards,<br>
Benjamin<br>
<br>
On 17.02.2009 22:08, MesDocs ParMail wrote:
<blockquote
 cite="mid:[email protected]"
 type="cite">
  <pre wrap="">Hello,

I code the template in the same manner as the web_templates.

The taglib has been translated. I found this line of code in the
resulting java file :

    _jspx_th_c_005fif_005f1.setTest(((java.lang.Boolean)
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${actusList.size
== 0 }", java.lang.Boolean.class, (PageContext)_jspx_page_context,
null, false)).booleanValue());

If I do not use the &lt;c:if&gt; tag to display the containers, these are
displayed correctly.

Kind regards,
Mesdocs.


2009/2/17 Sergiy Shyrkov <a class="moz-txt-link-rfc2396E" href="mailto:[email protected]">&lt;[email protected]&gt;</a>:
  </pre>
  <blockquote type="cite">
    <pre wrap="">Hello,

could you please ensure that your JSP has a tag library declaration for
JSTL core:
&lt;%@ taglib uri=<a class="moz-txt-link-rfc2396E" href="http://java.sun.com/jsp/jstl/core">"http://java.sun.com/jsp/jstl/core"</a> prefix="c" %&gt;

Can you check please the generated HTML code of the page? If if contains
 untranslated JSTL tags, than something is wrong with the JSTL tag lib
declaration.
The check ${empty actusList.size} is not quite correct as the
actusList.size is of type int. To check if the container list is empty
use: ${actusList.size == 0}

By the way, does the container list is getting displayed at all?

Kind regards
Sergiy

MesDocs ParMail wrote:
    </pre>
    <blockquote type="cite">
      <pre wrap="">Hello,

This the code i test. my_templates derives from web_templates.


&lt;template:containerList id="actusList" displayActionMenu="false"&gt;

    &lt;query:containerQuery&gt;
        &lt;query:selector nodeTypeName="my_templates:actusContainer"
selectorName="actusListSelector"/&gt;
        &lt;query:descendantNode selectorName="actusListSelector"
path="${currentSite.JCRPath}"/&gt;
        &lt;query:setProperty name="${queryConstants.SEARCH_MAX_HITS}"
value="${maxActus}" /&gt;
        &lt;query:sortBy propertyName="actusDate"
order="${queryConstants.ORDER_DESCENDING}"/&gt;
    &lt;/query:containerQuery&gt;

    &lt;c:if test="${empty actusList.size}"&gt;
      actusList is empty&lt;br/&gt;
    &lt;/c:if&gt;

    SIZE : ${actusList.size}

    &lt;c:if test="${actusList.size &gt; 1}"&gt;
              &lt;%@ include
file="../../../containers/actusContent/smallActusDisplay.jspf" %&gt;
    &lt;/c:if&gt;
    &lt;c:if test="${actusList.size == 1}"&gt;
      &lt;%@ include
file="../../../containers/actusContent/smallOneActuDisplay.jspf" %&gt;
    &lt;/c:if&gt;
&lt;/template:containerList&gt;

The ouptut :

actusList is empty
SIZE :


Kind regards
Medocs

2009/2/17 Sergiy Shyrkov <a class="moz-txt-link-rfc2396E" href="mailto:[email protected]">&lt;[email protected]&gt;</a>:
      </pre>
      <blockquote type="cite">
        <pre wrap="">Hello,


the following example shows how to get the size of a container list (no
matter if it is populated by a query or not - the size property is
available on  the ContainerListBean instance, exposed into its scope by
&lt;template:containerList/&gt; tag):

&lt;%@ taglib uri=<a class="moz-txt-link-rfc2396E" href="http://java.sun.com/jsp/jstl/core">"http://java.sun.com/jsp/jstl/core"</a> prefix="c" %&gt;
...
&lt;template:containerList name="events" id="eventsContainer"
actionMenuNamePostFix="events"
                       actionMenuNameLabelKey="events"
sortByField="${sortBy}" enforceDefinedSort="true" sortOrder="${order}"&gt;
   &lt;query:containerQuery&gt;
        &lt;query:selector nodeTypeName="web_templates:eventContainer"
selectorName="eventsSelector"/&gt;
       &lt;query:childNode selectorName="eventsSelector"
path="${eventsContainer.JCRPath}"/&gt;
           &lt;utility:dateUtil currentDate="${param.startDate}"
datePattern="dd/MM/yyyy" valueID="today" hours="0"
                             minutes="0"
                             seconds="0"/&gt;
           &lt;query:greaterThanOrEqualTo numberValue="true"
propertyName="startDate" value="${today.time}"/&gt;
   &lt;/query:containerQuery&gt;

   ...
   do display it
   ...
   We have ${eventsContainer.size}events

   &lt;c:if test="${eventsContainer.size &gt; 1}"&gt;
         we have multiple events
   &lt;/c:if&gt;
   &lt;c:if test="${eventsContainer.size == 1}"&gt;
         we have a single event
   &lt;/c:if&gt;
   &lt;c:if test="${eventsContainer.size == 0}"&gt;
         no events at all
   &lt;/c:if&gt;
&lt;/template:containerList&gt;


Could you give us, please, the example of code, you are trying to use?

Kind regards
Sergiy

MesDocs ParMail wrote:
        </pre>
        <blockquote type="cite">
          <pre wrap="">Hi,

I'd like to retrieve the size of a containerList populated by a query.
My page  will have different rendering if the result size is 1 or
more.

I have tested (and printed) the size attribute of the containerList
tag but it seemed to be empty.

How can I get this information ?

Thanks.

Mesdocs.
_______________________________________________
template_list mailing list
<a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a>
<a class="moz-txt-link-freetext" href="http://lists.jahia.org/cgi-bin/mailman/listinfo/template_list">http://lists.jahia.org/cgi-bin/mailman/listinfo/template_list</a>

          </pre>
        </blockquote>
        <pre wrap="">_______________________________________________
template_list mailing list
<a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a>
<a class="moz-txt-link-freetext" href="http://lists.jahia.org/cgi-bin/mailman/listinfo/template_list">http://lists.jahia.org/cgi-bin/mailman/listinfo/template_list</a>

        </pre>
      </blockquote>
      <pre wrap="">_______________________________________________
template_list mailing list
<a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a>
<a class="moz-txt-link-freetext" href="http://lists.jahia.org/cgi-bin/mailman/listinfo/template_list">http://lists.jahia.org/cgi-bin/mailman/listinfo/template_list</a>

      </pre>
    </blockquote>
    <pre wrap="">_______________________________________________
template_list mailing list
<a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a>
<a class="moz-txt-link-freetext" href="http://lists.jahia.org/cgi-bin/mailman/listinfo/template_list">http://lists.jahia.org/cgi-bin/mailman/listinfo/template_list</a>

    </pre>
  </blockquote>
  <pre wrap=""><!---->_______________________________________________
template_list mailing list
<a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a>
<a class="moz-txt-link-freetext" href="http://lists.jahia.org/cgi-bin/mailman/listinfo/template_list">http://lists.jahia.org/cgi-bin/mailman/listinfo/template_list</a>

  </pre>
</blockquote>
<br>
</body>
</html>

--===============1658634768==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
template_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/template_list

--===============1658634768==--