Why the searchContainer variable is unknown?

牧云@^-^@ 提交于 2019-12-08 11:00:51

问题


I'm trying to do a simple example with the searchContainer working with liferay 6.1.

The searchContainer variable is unknown in view.jsp. I get the error "searchContainer cannot be resolved".

I tried to include <%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>

It didn't work.

Code looks like this:

<liferay-ui:search-container iteratorURL="<%= actionURL %>" delta="10" emptyResultsMessage="no-documents">
<liferay-ui:search-container-results total="<%= list.size() %>" results="<%= ListUtil.subList(list, searchContainer.getStart(), searchContainer.getEnd()) %>" />

Update

I am using the varibale searchContainer in search-container-results tag and in the search-iterator tag

 <liferay-ui:search-container iteratorURL="<%= actionURL %>"
     delta="10" emptyResultsMessage="no-documents">
         <liferay-ui:search-container-results total="<%= list.size() %>"
         results="<%= ListUtil.subList(list, searchContainer.getStart(), 
         searchContainer.getEnd()) %>" />
         <liferay-ui:search-container-row modelVar="file        
         className="DLFileEntry">
         .
         .
         .
         </liferay-ui:search-container-row>
         <liferay-ui:search-iterator
          searchContainer="<%= searchContainer %>"
          paginate="${fn:length(listFiles) ge 10}" />
 </liferay-ui:search-container>

回答1:


In principle your code should work. I'd look for these options, in order of probability:

  1. Either you're cl the search-container tag before you use the search-container-results tag, thus searchContainer would be out of scope. (assuming you might have shortened the code here, or you have another reference to searchContainer, not just the one that you're showing here.
  2. or you're declaring the variable explicitly to be named differently, e.g. <liferay-ui:search-container var="myOwnNameForSearchContainer" ...>, again this assumes that you've severely shortened the sample code here
  3. or the tag library is not recognized (low probability).

How to mitigate?

  1. Watch out for other references to searchContainer later on the page, particularly after the occurrence of </liferay-ui:search-container>.
  2. should be obvious
  3. Shorten the page to just <liferay-ui:searchContainer ... > </liferay-ui:search-container> and make sure that this gets replaced with actual HTML code, and this particular markup is no longer existing in the HTML output when you render the page, then add individual other elements.


来源:https://stackoverflow.com/questions/46811395/why-the-searchcontainer-variable-is-unknown

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!