Fórum

error: searchContainer cannot be resolved

Jason Sledge, modificado 10 Anos atrás.

error: searchContainer cannot be resolved

New Member Postagens: 2 Data de Entrada: 23/01/14 Postagens Recentes
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>

<%
}
%>
Scarletake Bwi, modificado 3 Anos atrás.

RE: error: searchContainer cannot be resolved

Expert Postagens: 326 Data de Entrada: 20/12/10 Postagens Recentes
i'm facing same issue.

someone help?
thumbnail
Ravi Kumar Gupta, modificado 10 Anos atrás.

RE: error: searchContainer cannot be resolved

Liferay Legend Postagens: 1302 Data de Entrada: 24/06/09 Postagens Recentes
The code below alone works fine.. so should your's. Can you please share server log?

&lt;%@page import="com.test.service.service.CityLocalServiceUtil"%&gt;
&lt;%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui"%&gt;
&lt;%
int count = 0;
%&gt;
<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.">
			&lt;%=++count %&gt;	
		</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, modificado 10 Anos atrás.

RE: error: searchContainer cannot be resolved

New Member Postagens: 2 Data de Entrada: 23/01/14 Postagens Recentes
Ah, same here Ravi.

Eclipse reports an error but it does execute.
Thanks for the reply.
thumbnail
Kamil Grzegorz Chomicki, modificado 10 Anos atrás.

RE: error: searchContainer cannot be resolved

New Member Postagens: 3 Data de Entrada: 18/10/11 Postagens Recentes
Hi,

maybe someone find any workaround? because is difficult to develop when IDE does not show hints and reports bugs.

Best Regards
Djordje Petrovic, modificado 10 Anos atrás.

RE: error: searchContainer cannot be resolved

New Member Postagens: 2 Data de Entrada: 08/10/13 Postagens Recentes
Ravi, Kamil
try adding this at the top of your jsp :


&lt;%!
   com.liferay.portal.kernel.dao.search.SearchContainer<city> searchContainer = null;
%&gt;
</city>


It's not a perfect solution, but it's working (in my case).
Prashant Chandra, modificado 10 Anos atrás.

RE: error: searchContainer cannot be resolved

New Member Postagens: 11 Data de Entrada: 04/06/13 Postagens Recentes
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
Djordje Petrovic, modificado 10 Anos atrás.

RE: error: searchContainer cannot be resolved

New Member Postagens: 2 Data de Entrada: 08/10/13 Postagens Recentes
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.
Tarun Kshatriya, modificado 7 Anos atrás.

RE: error: searchContainer cannot be resolved

New Member Mensagem: 1 Data de Entrada: 14/09/16 Postagens Recentes
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.