您的位置:首页 > Web前端

Liferay研究之四:列表显示jsp分析

2007-11-23 14:15 351 查看
显示文章列表的jsp页面是journal_articles/view.jsp,其中用了一个liferay自定义的标签:
<liferay-ui:search-iterator searchContainer="<%= searchContainer %>" />

该标签由:liferay-ui.tld定义,是由:com.liferay.taglib.ui.SearchIteratorTag 来解析的。
从SearchIteratorTag代码中可以知道,里面会调用一个标签属性:paginate,且缺省页面是html/taglib/ui/search_iterator/page.jsp。
从中可以知道,需要先判断是否分页:
<c:if test="<%= paginate %>">

如果需要分页,则调用分页专用的tag标签。
<liferay-ui:search-paginator searchContainer="<%= searchContainer %>" />

之后,通过headerNames来显示表头,如果将其clear,那么就不显示表头。
接下来判断,如果没有查询结果,则显示无结果的显示内容。比如“没有查询结果”之类;
然后设置每行显示的className 样式表类;之后就开始显示表中的内容。注意,row.getEntries()获得一行的所有列,entry.print(pageContext)显示列的内容;
最后显示列表的bottom内容。
 <c:if test="<%= (resultRows.size() > 10) && paginate %>">
  <div class="taglib-search-iterator-page-iterator-bottom">
   <liferay-ui:search-paginator searchContainer="<%= searchContainer %>" />
  </div>
 </c:if>

这里有点迷糊,不知道这个bottom的具体作用,可能只是添加一个html </form>标记。或者还有什么内容,或者只是与taglib-search-iterator-page-iterator-top成对出现?

此外,有一个Bug, 如果分页点击下一页时会显示下一个记录的详细内容,而不是下一页列表,查看源代码可能是没有设置searchContainer.iteratorURL

显示文章列表信息的相关页面有:
html/taglib/ui/page_iterator/start.jsp
Near 85 line:
 <div class="search-results">
  <c:choose>
   <c:when test="<%= total > resultRowsSize %>">
    <%= LanguageUtil.format(pageContext, "showing-x-x-of-x-results", new Object[] {String.valueOf(start + 1), String.valueOf(end), String.valueOf(total)}) %>
   </c:when>
   <c:otherwise>
    <c:choose>
     <c:when test="<%= total != 1 %>">
      <%= LanguageUtil.format(pageContext, "showing-x-results", String.valueOf(total)) %>
     </c:when>
     <c:otherwise>
      <%= LanguageUtil.format(pageContext, "showing-x-result", String.valueOf(total)) %>
     </c:otherwise>
    </c:choose>
   </c:otherwise>
  </c:choose>
 </div>

将上面代码删除,可不显示:当前共xx条。的文字;

显示:页 xx 的xx ,选择第几页的代码:
Near 105 line (original code):
   <div class="page-selector">
    <liferay-ui:message key="page" />

    <select class="pages <%= namespace %>pageIteratorValue">

     <%
     for (int i = 1; i <= pages; i++) {
     %>

      <option <%= (i == curValue) ? "selected=/"selected/"" : "" %> value="<%= i %>"><%= i %></option>

     <%
     }
     %>

    </select>

    <liferay-ui:message key="of" />

    <%= pages %>

    <input class="page-iterator-submit" type="submit" value="<liferay-ui:message key="submit" />" />
   </div>

显示分页控制的代码:
Near 129 line(original code):
   <div class="page-links">
    <c:choose>
     <c:when test="<%= curValue != 1 %>">
      <a class="first" href="<%= _getHREF(formName, curParam, 1, jsCall, url, urlAnchor) %>" target="<%= target %>">
     </c:when>
     <c:otherwise>
      <span class="first">
     </c:otherwise>
    </c:choose>

    <liferay-ui:message key="first" />

    <c:choose>
     <c:when test="<%= curValue != 1 %>">
      </a>
     </c:when>
     <c:otherwise>
      </span>
     </c:otherwise>
    </c:choose>

    <c:choose>
     <c:when test="<%= curValue != 1 %>">
      <a class="previous" href="<%= _getHREF(formName, curParam, curValue - 1, jsCall, url, urlAnchor) %>" target="<%= target %>">
     </c:when>
     <c:otherwise>
      <span class="previous">
     </c:otherwise>
    </c:choose>

    <liferay-ui:message key="previous" />

    <c:choose>
     <c:when test="<%= curValue != 1 %>">
      </a>
     </c:when>
     <c:otherwise>
      </span>
     </c:otherwise>
    </c:choose>

    <c:choose>
     <c:when test="<%= curValue != pages %>">
      <a class="next" href="<%= _getHREF(formName, curParam, curValue + 1, jsCall, url, urlAnchor) %>" target="<%= target %>">
     </c:when>
     <c:otherwise>
      <span class="next">
     </c:otherwise>
    </c:choose>

    <liferay-ui:message key="next" />

    <c:choose>
     <c:when test="<%= curValue != pages %>">
      </a>
     </c:when>
     <c:otherwise>
      </span>
     </c:otherwise>
    </c:choose>

    <c:choose>
     <c:when test="<%= curValue != pages %>">
      <a class="last" href="<%= _getHREF(formName, curParam, pages, jsCall, url, urlAnchor) %>" target="<%= target %>">
     </c:when>
     <c:otherwise>
      <span class="last">
     </c:otherwise>
    </c:choose>

    <liferay-ui:message key="last" />

    <c:choose>
     <c:when test="<%= curValue != pages %>">
      </a>
     </c:when>
     <c:otherwise>
      </span>
     </c:otherwise>
    </c:choose>
   </div>

 

html/portlet/journal_articles/view.jsp
Near 56 line:
  //headerNames.add("name");
  //headerNames.add("display-date");
  //headerNames.add("author");

将上述代码注释掉之后,可以不显示表的表头。“文章、作者、日期”等。 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  jsp class c div url object