Search code examples
liferayliferay-7soy-templatesmetal.js

How to create simple data presentation portlet for liferay 7.0?


I need to create simple data presentation portlet for new version of liferay, but can't really find the proper way.

I created backend with service builder and added custom methods for listing, adding, etc. Created mvc portlet based on this tutorial [https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/updating-the-view] and it works, but there is some problems: - It is based on deprecated alloyUI and I wan't to move it to soy/metal.js (don't have any experience with any of them), - result table should have sorting/filtering capabilities, server side probably because it have to be compatible with WCAG so I wan't to keep html and js as clean as possible.

If I understand properly, I need to replace this part below for something that works with metal.js and soy?

<liferay-ui:search-container total="<%=EntryLocalServiceUtil.getEntriesCount()%>">
<liferay-ui:search-container-results
    results="<%=EntryLocalServiceUtil.getEntries(scopeGroupId.longValue(),
                    guestbookId, searchContainer.getStart(),
                    searchContainer.getEnd())%>" />    
<liferay-ui:search-container-row
    className="com.liferay.docs.guestbook.model.Entry" modelVar="entry">    
    <liferay-ui:search-container-column-text property="message" />    
    <liferay-ui:search-container-column-text property="name" />    
</liferay-ui:search-container-row>    
<liferay-ui:search-iterator />    
</liferay-ui:search-container>

How is sorting/filtering implemented in liferay-7.0? Do I have to use management bar or is it possible to allow users to sort by column (clicking on column header).


Solution

  • I would not change the code. You are not using AlloyUI but Liferay UI tags which currently happen to use AlloyUI but will eventually switch to Metal.

    If you want to stay with the server side rendering I would not waste effort on redeveloping search container. It should work fine now and will in the future.

    Sorting should be supported by the search container. You just need to indicate it in the columns but filtering is more tricky. Liferay does more search then filtering.