留言板
error: searchContainer cannot be resolved
Jason Sledge,修改在10 年前。
error: searchContainer cannot be resolved
New Member 帖子: 2 加入日期: 14-1-23 最近的帖子
I am attempting to get a simple example with the searchContainer working with liferay 6.2.
the searchContainer variable is unknown in view.jsp. I get the error "searchContainer cannot be resolved"
If I replace the function calls to searchContainer.getStart() and searchContainer.getEnd() with literal numbers like 1, 2 then the code executes without any problems.
Am I missing something obvious ?
I have included the taglib with
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
code looks like this:
<%
List<CBMMainQuery> searchResults = (List<CBMMainQuery>)renderRequest.getPortletSession().getAttribute("srch") ;
if(searchResults != null) {
%>
<liferay-ui:search-container delta="1" emptyResultsMessage="No Items were found!!">
<liferay-ui:search-container-results results="<%=ListUtil.subList(searchResults, searchContainer.getStart(),searchContainer.getEnd())%>" total="${searchResults.size()}" />
<liferay-ui:search-container-row className="mil.peoavn.caps.model.CBMMainQueryModel"
modelVar="cbmq">
<liferay-ui:search-container-column-text name="datatype" value="<%=String.valueOf(cbmq.getDataType()) %>" />
<liferay-ui:search-container-column-text name="dttext" value="<%=cbmq.getDtText() %>" />
</liferay-ui:search-container-row>
<liferay-ui:search-iterator />
</liferay-ui:search-container>
<%
}
%>
the searchContainer variable is unknown in view.jsp. I get the error "searchContainer cannot be resolved"
If I replace the function calls to searchContainer.getStart() and searchContainer.getEnd() with literal numbers like 1, 2 then the code executes without any problems.
Am I missing something obvious ?
I have included the taglib with
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
code looks like this:
<%
List<CBMMainQuery> searchResults = (List<CBMMainQuery>)renderRequest.getPortletSession().getAttribute("srch") ;
if(searchResults != null) {
%>
<liferay-ui:search-container delta="1" emptyResultsMessage="No Items were found!!">
<liferay-ui:search-container-results results="<%=ListUtil.subList(searchResults, searchContainer.getStart(),searchContainer.getEnd())%>" total="${searchResults.size()}" />
<liferay-ui:search-container-row className="mil.peoavn.caps.model.CBMMainQueryModel"
modelVar="cbmq">
<liferay-ui:search-container-column-text name="datatype" value="<%=String.valueOf(cbmq.getDataType()) %>" />
<liferay-ui:search-container-column-text name="dttext" value="<%=cbmq.getDtText() %>" />
</liferay-ui:search-container-row>
<liferay-ui:search-iterator />
</liferay-ui:search-container>
<%
}
%>
Scarletake Bwi,修改在3 年前。
RE: error: searchContainer cannot be resolved
Expert 帖子: 326 加入日期: 10-12-20 最近的帖子
i'm facing same issue.
someone help?
someone help?
Ravi Kumar Gupta,修改在10 年前。
RE: error: searchContainer cannot be resolved
Liferay Legend 帖子: 1302 加入日期: 09-6-24 最近的帖子
The code below alone works fine.. so should your's. Can you please share server log?
In JSP file I do get the error same as yours but it executes without any problem.
<%@page import="com.test.service.service.CityLocalServiceUtil"%>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui"%>
<%
int count = 0;
%>
<liferay-ui:search-container delta="100" emptyresultsmessage="no-cities-were-found">
<liferay-ui:search-container-results results="<%=CityLocalServiceUtil.getCities(searchContainer.getStart(), searchContainer.getEnd())%>" total="<%=CityLocalServiceUtil.getCitiesCount()%>" />
<liferay-ui:search-container-row classname="com.test.service.model.City" keyproperty="cityId" modelvar="city">
<liferay-ui:search-container-column-text name="S.No.">
<%=++count %>
</liferay-ui:search-container-column-text>
<liferay-ui:search-container-column-text name="name" value="<%=city.getName()%>" />
<liferay-ui:search-container-column-text name="Lattitude" cssClass="lat" property="lattitude" />
<liferay-ui:search-container-column-text name="Longitude" cssClass="lon" property="longitude" />
</liferay-ui:search-container-row>
<liferay-ui:search-iterator />
</liferay-ui:search-container>
<liferay-ui:search-container delta="10" emptyResultsMessage="no-users-were-found" />
In JSP file I do get the error same as yours but it executes without any problem.
Jason Sledge,修改在10 年前。
RE: error: searchContainer cannot be resolved
New Member 帖子: 2 加入日期: 14-1-23 最近的帖子
Ah, same here Ravi.
Eclipse reports an error but it does execute.
Thanks for the reply.
Eclipse reports an error but it does execute.
Thanks for the reply.
Kamil Grzegorz Chomicki,修改在10 年前。
RE: error: searchContainer cannot be resolved
New Member 帖子: 3 加入日期: 11-10-18 最近的帖子
Hi,
maybe someone find any workaround? because is difficult to develop when IDE does not show hints and reports bugs.
Best Regards
maybe someone find any workaround? because is difficult to develop when IDE does not show hints and reports bugs.
Best Regards
Djordje Petrovic,修改在10 年前。
RE: error: searchContainer cannot be resolved
New Member 帖子: 2 加入日期: 13-10-8 最近的帖子
Ravi, Kamil
try adding this at the top of your jsp :
It's not a perfect solution, but it's working (in my case).
try adding this at the top of your jsp :
<%!
com.liferay.portal.kernel.dao.search.SearchContainer<city> searchContainer = null;
%>
</city>
It's not a perfect solution, but it's working (in my case).
Prashant Chandra,修改在10 年前。
RE: error: searchContainer cannot be resolved
New Member 帖子: 11 加入日期: 13-6-4 最近的帖子
Yes, We need to create before using it in jsp. Hope it helps you..
SearchContainer mainSearchSearchContainer = new SearchContainer(renderRequest, null, null, SearchContainer.DEFAULT_CUR_PARAM, SearchContainer.DEFAULT_DELTA, portletURL, null, LanguageUtil.format(pageContext, "no-results-were-found-that-matched-the-keywords-x", "<strong>" + HtmlUtil.escape(keywords) + "</strong>"));
Prashant
SearchContainer mainSearchSearchContainer = new SearchContainer(renderRequest, null, null, SearchContainer.DEFAULT_CUR_PARAM, SearchContainer.DEFAULT_DELTA, portletURL, null, LanguageUtil.format(pageContext, "no-results-were-found-that-matched-the-keywords-x", "<strong>" + HtmlUtil.escape(keywords) + "</strong>"));
Prashant
Djordje Petrovic,修改在10 年前。
RE: error: searchContainer cannot be resolved
New Member 帖子: 2 加入日期: 13-10-8 最近的帖子
Prashant, we do not need to create this variable, we need only to declare it.
In a process of compiling *.jsp into *_jsp.java, this variable WILL be created (inside _jspService method) anyway, without our effort.
The only problem is that our IDE (Eclipse, Liferay Developer Studio, etc) does not know that.
So, we just have to fool it and let it know that such variable does exist.
However, we have to define it on "a class level" (that's why we need that exclamation mark) because, without it, we will get "duplicated variable" error.
The servlet will never use "our" (class-level) variable, but the method-level (automatically created) version of it.
In a process of compiling *.jsp into *_jsp.java, this variable WILL be created (inside _jspService method) anyway, without our effort.
The only problem is that our IDE (Eclipse, Liferay Developer Studio, etc) does not know that.
So, we just have to fool it and let it know that such variable does exist.
However, we have to define it on "a class level" (that's why we need that exclamation mark) because, without it, we will get "duplicated variable" error.
The servlet will never use "our" (class-level) variable, but the method-level (automatically created) version of it.
Tarun Kshatriya,修改在7 年前。
RE: error: searchContainer cannot be resolved
New Member 发布: 1 加入日期: 16-9-14 最近的帖子
Please ensure that in liferay-ui:search-container-column-text property="abc" there are no properties for which column (for ex. "abc") doesn't exist in the service builder DB tables.