问题
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:
- 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.
- 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 - or the tag library is not recognized (low probability).
How to mitigate?
- Watch out for other references to
searchContainer
later on the page, particularly after the occurrence of</liferay-ui:search-container>
. - should be obvious
- 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