Fórum

Search container with Spring MVC.

James charley, modificado 10 Anos atrás.

Search container with Spring MVC.

Junior Member Postagens: 44 Data de Entrada: 12/06/13 Postagens Recentes
Team,

I am trying to integrate Spring MVC with search container to separate business logic from view.

I wrote following code in controller to prepare model data.

Controller : -

SearchContainer<user> searchContainer = new SearchContainer<user>(
renderRequest, null, null, SearchContainer.DEFAULT_CUR_PARAM,
ParamUtil.getInteger(renderRequest,
SearchContainer.DEFAULT_DELTA_PARAM, 1), iteratorURL,
null, LanguageUtil.get(portletConfig, themeDisplay.getLocale(),
"No Users were Found"));

int total = 0;
userList = new ArrayList<user>();

user user = new user();
user.setFirstname("Test1");
userList.add(user);

user user1 = new user();
user1.setFirstname("test2");

userList.add(user1);
total = userList.size();

userList = ListUtil.subList(userList, searchContainer.getStart(),
searchContainer.getEnd());
searchContainer.setTotal(total);
searchContainer.setResults(userList);
modelView.addObject("results",userList);
modelView.addObject("total",total)
modelView.addObject("searchcontainer",searchContainer);


Code in the View :

<liferay-ui:search-container searchContainer="${searchcontainer}">
<liferay-ui:search-container-results total="${total}" results="${results}">
<liferay-ui:search-container-row className="com.myowncompany.test.springmvc.controller.user" >
<liferay-ui:search-container-column-text name="First Name" property="firstname" />
</liferay-ui:search-container-row>

<liferay-ui:search-iterator/>
</liferay-ui:search-container-results>

</liferay-ui:search-container>



I am getting following error. Not able to understand what is happening.

Caused by: javax.servlet.ServletException: javax.servlet.jsp.JspException: Requires liferay-ui:search-container-results
at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:911)
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:840)
at com.liferay.portal.kernel.servlet.PageContextWrapper.handlePageException(PageContextWrapper.java:161)
at org.apache.jsp.WEB_002dINF.jsp.defaultRender_jsp._jspService(defaultRender_jsp.java:417)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
... 198 more
Caused by: javax.servlet.jsp.JspException: Requires liferay-ui:search-container-results
at com.liferay.taglib.ui.SearchContainerRowTag.doStartTag(SearchContainerRowTag.java:138)
at org.apache.jsp.WEB_002dINF.jsp.defaultRender_jsp._jspService(defaultRender_jsp.java:222)
... 201 more
12:32:36,173 ERROR [http-bio-8080-exec-1][render_portlet_jsp:154] javax.servlet.jsp.JspException: Requires liferay-ui:search-container-results
at com.liferay.taglib.ui.SearchContainerRowTag.doStartTag(SearchContainerRowTag.java:138)
at org.apache.jsp.WEB_002dINF.jsp.defaultRender_jsp._jspService(defaultRender_jsp.java:222)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
James charley, modificado 10 Anos atrás.

RE: Search container with Spring MVC.

Junior Member Postagens: 44 Data de Entrada: 12/06/13 Postagens Recentes
Team,

Any update on this I am kind of stuck with this.

Thanks.
ibo2013 ibo, modificado 10 Anos atrás.

RE: Search container with Spring MVC.

New Member Postagens: 2 Data de Entrada: 06/11/13 Postagens Recentes
Hi,
i have the same error, and I am stuck, can you help me, or can you geta solution, or an idea. please,

thank u very much
Peter Drábik, modificado 9 Anos atrás.

RE: Search container with Spring MVC.

New Member Postagens: 2 Data de Entrada: 23/01/15 Postagens Recentes
This error occurs because your search-container-row tag has to be outside search-container-results tag. The search-container-results tag should not contain any other tags, AFAIK. Wiki article is wrong.
thumbnail
Aditya Bhardwaj, modificado 9 Anos atrás.

RE: Search container with Spring MVC.

Junior Member Postagens: 78 Data de Entrada: 08/01/15 Postagens Recentes
Hi,

Your tags are not properly closed like result tag. If you are using IDE you can generate the code with the help of Snipplets.
For Example see this code:-


<liferay-ui:search-container delta="5" deltaConfigurable="true">
<liferay-ui:search-container-results results="<%= StudentLocalServiceUtil.getStudents(searchContainer.getStart(), searchContainer.getEnd()) %>" total="<%= StudentLocalServiceUtil.getStudentsCount() %>"/>

<liferay-ui:search-container-row className="com.student.services.model.Student" modelVar="aStudent" keyProperty="studentId">

<portlet:renderURL var="rowURL">
<portlet:param name="backURL" value="<%= currentURL %>" />
<portlet:param name="studentId" value="<%= String.valueOf(aStudent.getStudentId()) %>" />
<portlet:param name="click" value="link"/>
</portlet:renderURL>

<liferay-ui:search-container-column-text property="name" name="Student Name" href="<%= rowURL %>"/>

<liferay-ui:search-container-column-text property="lastname" name="Sir Name" />
<liferay-ui:search-container-column-text property="phone" name="Contact Number"/>
<liferay-ui:search-container-column-text property="std" name = "Class" />
<liferay-ui:search-container-column-text name="Gender" value='<%=(aStudent.getGender()==1)?"Male":"Female"%>'/>
<liferay-ui:search-container-column-jsp name="Address" align="left" path="/html/seachcontainer/address.jsp"/>
<liferay-ui:search-container-column-text href="<%= rowURL %>" name="Detail" value="Detail"/>
</liferay-ui:search-container-row>

<liferay-ui:search-iterator />
</liferay-ui:search-container>
Peter Drábik, modificado 9 Anos atrás.

RE: Search container with Spring MVC.

New Member Postagens: 2 Data de Entrada: 23/01/15 Postagens Recentes
His tags are closed properly, structure is not proper.