Foros de discusión

[RESOLVED] iteratorURL fails (pagination)

thumbnail
Fabio Foglia, modificado hace 12 años.

[RESOLVED] iteratorURL fails (pagination)

Junior Member Mensajes: 61 Fecha de incorporación: 2/09/11 Mensajes recientes
Hello All,

I haven't found any solution to this, hope, simple problem.

<liferay-ui:search-container iteratorURL="<%= iteratorURL %>" delta="5" emptyResultsMessage="No Results Were found for the Selected Criteria">

iteratorURL doesn't work for page different from view.jsp.

In this case "next page" redirect to view.jsp.

I've tryied with "PortletURL iteratorURL = renderResponse.createActionURL();" with no result.

If I add "iteratorURL.setParameter("jspPage", "/list.jsp");" to iteratorURL , I'm then unable to pass objects in request needed by list.jsp.

My last code is below:

<%
PortletURL iteratorURL = renderResponse.createRenderURL();
List<?> tempResults = (List<?>) request.getAttribute("allegatiRichiesta");
%>
<liferay-ui:search-container iteratorURL="<%= iteratorURL %>" delta="5" emptyResultsMessage="No Results Were found for the Selected Criteria">
<liferay-ui:search-container-results
total="<%= tempResults.size() %>"
results="<%= ListUtil.subList(tempResults,searchContainer.getStart(),searchContainer.getEnd()) %>"
/>
<liferay-ui:search-container-row className="java.lang.Object[]" modelVar="allegato">
<liferay-ui:search-container-column-text name="Descr" value="<%= all[6]!=null ? all[6].toString() : \"\" %>"/>
<liferay-ui:search-container-column-text name="Date" value="<%= all[7]!=null ? sdf.format((Date)all[7]) : \"\" %>"/>
</liferay-ui:search-container-row>
<liferay-ui:search-iterator searchContainer="<%= searchContainer %>" />
</liferay-ui:search-container>



Anyone has the solution?

Thank you

Fabio
thumbnail
Fabio Foglia, modificado hace 12 años.

[RESOLVED iteratorURL fails

Junior Member Mensajes: 61 Fecha de incorporación: 2/09/11 Mensajes recientes
Fabio Foglia:
Hello All,

I haven't found any solution to this, hope, simple problem.

<liferay-ui:search-container iteratorURL="<%= iteratorURL %>" delta="5" emptyResultsMessage="No Results Were found for the Selected Criteria">

iteratorURL doesn't work for page different from view.jsp.

In this case "next page" redirect to view.jsp.

I've tryied with "PortletURL iteratorURL = renderResponse.createActionURL();" with no result.

If I add "iteratorURL.setParameter("jspPage", "/list.jsp");" to iteratorURL , I'm then unable to pass objects in request needed by list.jsp.

My last code is below:

<%
PortletURL iteratorURL = renderResponse.createRenderURL();
List<?> tempResults = (List<?>) request.getAttribute("allegatiRichiesta");
%>
<liferay-ui:search-container iteratorURL="<%= iteratorURL %>" delta="5" emptyResultsMessage="No Results Were found for the Selected Criteria">
<liferay-ui:search-container-results
total="<%= tempResults.size() %>"
results="<%= ListUtil.subList(tempResults,searchContainer.getStart(),searchContainer.getEnd()) %>"
/>
<liferay-ui:search-container-row className="java.lang.Object[]" modelVar="allegato">
<liferay-ui:search-container-column-text name="Descr" value="<%= all[6]!=null ? all[6].toString() : \"\" %>"/>
<liferay-ui:search-container-column-text name="Date" value="<%= all[7]!=null ? sdf.format((Date)all[7]) : \"\" %>"/>
</liferay-ui:search-container-row>
<liferay-ui:search-iterator searchContainer="<%= searchContainer %>" />
</liferay-ui:search-container>



Anyone has the solution?

Thank you

Fabio



After a day of work I found a solution (don't know if the best).

The key is to pass objects in session as follow:

LINK TO CALL ACTION:

<aui:layout>
<aui:column>
<portlet:actionURL var="showListURL" name="showList">
<portlet:param name="jspPage" value="/list.jsp" />
</portlet:actionURL>
<liferay-ui:icon image="clip" message="Documenti Richiesta" url="<%= showListURL %>" />
</aui:column>
<aui:column first="true">
<label class="aui-field-label">SHOW LIST</label>
</aui:column>
</aui:layout>

CALLING ACTION:

public void showList(ActionRequest actionRequest, ActionResponse actionResponse){
List<?> list = "code to get your list"

HttpSession session = PortalUtil.getHttpServletRequest(actionRequest).getSession();
session.setAttribute("list", list);

SessionMessages.add(actionRequest, "");
actionResponse.setRenderParameter("jspPage",actionRequest.getParameter("jspPage"));
}

JSP (list.jsp):

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page import="javax.portlet.PortletURL" %>
<%@ page import="com.liferay.portlet.PortletURLUtil" %>
<%@ page import="com.liferay.portal.kernel.util.ParamUtil" %>
<%@ page import="com.liferay.portal.kernel.util.ListUtil" %>
<%@ page import="java.util.List" %>
<%@ page import="javax.portlet.ActionRequest" %>

<portlet:defineObjects />

<%
PortletURL iteratorURL = renderResponse.createRenderURL();
iteratorURL.setParameter("jspPage", "/list.jsp");
iteratorURL.setParameter(ActionRequest.ACTION_NAME,"showList");
List<?> tempResults = (List<?>) session.getAttribute("list");
%>

<liferay-ui:search-container delta="20" iteratorURL="<%= iteratorURL %>" emptyResultsMessage="Non items">
<liferay-ui:search-container-results
total="<%= tempResults.size() %>"
results="<%= ListUtil.subList(tempResults,searchContainer.getStart(),searchContainer.getEnd()) %>"/>
<liferay-ui:search-container-row className="java.lang.Object[]" modelVar="item">
<liferay-ui:search-container-column-text name="Id" value="<%= item[0]!=null ? item[0].toString() : \"\" %>"/>
<liferay-ui:search-container-column-text name="Descr" value="<%= item[1]!=null ? item[1].toString() : \"\" %>"/>
</liferay-ui:search-container-row>
<liferay-ui:search-iterator />
</liferay-ui:search-container>

Hope to be useful for community...
A S, modificado hace 11 años.

RE: [RESOLVED iteratorURL fails

New Member Mensajes: 19 Fecha de incorporación: 30/04/12 Mensajes recientes
I think you came to the right conclusion here, have implemented likewise. To be fair, the session approach is actually beneficial later on in development when you want to return to a list from an edit screen for instance after update / cancel. I was somewhat caught out by having to update the object in the list in the session as well as the database, for it to reflect to the user correctly upon their return though. Otherwise, all working nicely.

Cheers for the solution.

A
thumbnail
Laura Liparulo, modificado hace 11 años.

RE: [RESOLVED iteratorURL fails

Junior Member Mensajes: 38 Fecha de incorporación: 30/06/12 Mensajes recientes
Take a look at my solution :-)

http://www.liferay.com/community/forums/-/message_boards/message/21031639
Vimek Vanamali, modificado hace 9 años.

RE: [RESOLVED iteratorURL fails

New Member Mensajes: 16 Fecha de incorporación: 6/04/14 Mensajes recientes
emoticon Thank you .your snippet helped me alot.In my case i had to pass my user along with the attributes