How to use two (multiple) Lideray UI Search Container tags in one JSP

I need to use two different <liferay-ui:search-container> in one JSP.

Displaying pages gives problems if we use two <liferay-ui:search-container> :

  • When I click on the third page of the first <liferay-ui:search-container> tag, the second <liferay-ui:search-container> also moves to the third page.

  • Also, if for the first <liferay-ui:search-container> I am on page 3 and I click on page-2 of the second <liferay-ui:search-container> , and the second tag goes to page-2, but The first results of the reset tag on page-1.

They must be independent of each other.

Environment: Liferay 6. +

+4
source share
1 answer

I found two different ways to do this:

  • This is possible using the curParam attribute in the <liferay-ui:search-container> , seen by curParam="folderCurParam" and curParam="fileCurParam" in the following code, I found this path through liferay source code docroot/html/portlet/document_library_display/view.jsp and docroot/html/portlet/document_library_display/view_file_entries.jspf :

     <liferay-ui:search-container curParam="folderCurParam" emptyResultsMessage="no-folders-to-display" iteratorURL="<%= portletURL %>" delta="10"> <liferay-ui:search-container-results results="<%=folderResults %>" total="<%= folderTotal %>" /> <liferay-ui:search-container-row className="com.liferay.portal.kernel.repository.model.Folder" keyProperty="userId" modelVar="folder"> <liferay-ui:search-container-column-jsp align="left" path="/html/documentdisplay/folder_search_results.jsp" /> </liferay-ui:search-container-row> <liferay-ui:search-iterator /> </liferay-ui:search-container> <liferay-ui:search-container curParam="fileCurParam" emptyResultsMessage="no-files-to-display" iteratorURL="<%= portletURL %>" delta="10"> <liferay-ui:search-container-results results="<%=fileResults %>" total="<%= fileTotal %>" /> <liferay-ui:search-container-row className="com.liferay.portal.kernel.repository.model.FileEntry" keyProperty="userId" modelVar="fileEntry"> <liferay-ui:search-container-column-jsp align="left" path="/html/documentdisplay/files_search_results.jsp" /> </liferay-ui:search-container-row> <liferay-ui:search-iterator /> </liferay-ui:search-container> 
  • I found this again in the liferay source code docroot docroot/html/portlet/journal/select_document_library.jsp , the docroot/html/portlet/journal/select_document_library.jsp constructor is used here to set curParam , pay attention to the parameter "cur1" for folders, and for files - "cur2" :

     // for folders SearchContainer searchContainer = new SearchContainer(renderRequest, null, null, "cur1", SearchContainer.DEFAULT_DELTA, portletURL, headerNames, "there-are-no-folders"); // for files searchContainer = new SearchContainer(renderRequest, null, null, "cur2", SearchContainer.DEFAULT_DELTA, portletURL, headerNames, "there-are-no-documents-in-this-folder"); 

Hope this helps someone.

+5
source

All Articles