Tuesday, April 18, 2017

Liferay7: Changes in search container tag

Hi,

Liferay search container is the very common practice for liferay developer to display list of data. So, here is am writing something interesting for search container in liferay new version called Liferay7 or Liferay DXP.

Earlier or older version, we use or setup search container tag like below....

<liferay-ui:search-container
emptyResultsMessage="no-users-were-found"
iteratorURL="<%= iteratorURL %>"
>
          <liferay-ui:search-container-results
                   results="<%= UserLocalServiceUtil.getUser(themeDisplay.getUserId()), searchContainer.getStart(), searchContainer.getEnd(), searchContainer.getOrderByComparator()) %>"
                     total="<%= UserLocalServiceUtil.getUser(themeDisplay.getUserId()).size() %>"
        />
       ...
       ...
       ...
</liferay-ui:search-container>


result & total attribute are configure in the liferay-ui:search-container-results tag. While in DXP version the total attribute move to the liferay-ui:search-container tag. So, we just have to
setup results attribute into liferay-ui:search-container-results. Below is the example how we use search container in liferay7 or DXP.


<liferay-ui:search-container
emptyResultsMessage="no-users-were-found"
iteratorURL="<%= iteratorURL %>"
 total="<%= UserLocalServiceUtil.getUserCount(themeDisplay.getUserId()) %>"
>
              <liferay-ui:search-container-results
                      results="<%= UserLocalServiceUtil.getUser(themeDisplay.getUserId()), searchContainer.getStart(), searchContainer.getEnd(), searchContainer.getOrderByComparator()) %>"            
             />
       ...
       ...
       ...
</liferay-ui:search-container>


total is moved from liferay-ui:search-container-results to liferay-ui:search-container tag is only change in search container in Liferay7 or DXP.

HTH!!

Regards,
Ketan Savaliya

1 comment:

  1. Incroyable... c'est une méthode si simple. Merci de partager cette méthode avec nous. Nous sommes Liferay Expert France et proposons les services Liferay. Contactez-nous pour obtenir plus de détails.

    ReplyDelete