日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

liferay-ui:search-container 用法

發布時間:2023/12/20 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 liferay-ui:search-container 用法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

2019獨角獸企業重金招聘Python工程師標準>>>

liferay 提供<liferay-ui:search-container>標簽 方便實現查詢翻頁功能:

<liferay-ui:search-container delta="10" emptyResultsMessage="no-users-were-found"><liferay-ui:search-container-resultsresults="<%= UserLocalServiceUtil.search(company.getCompanyId(), searchTerms.getKeywords(), searchTerms.getActiveObj(), userParams, searchContainer.getStart(), searchContainer.getEnd(),searchContainer.getOrderByComparator()); %>"total="<%= UserLocalServiceUtil.searchCount(company.getCompanyId(), searchTerms.getKeywords(), searchTerms.getActiveObj(), userParams); %>"/><liferay-ui:search-container-rowclassName="com.liferay.portal.model.User"keyProperty="userId"modelVar="user"><liferay-ui:search-container-column-textname="name"value="<%= user.getFullName() %>"/><liferay-ui:search-container-column-textname="first-name"property="firstName"/></liferay-ui:search-container-row><liferay-ui:search-iterator /></liferay-ui:search-container><liferay-ui:search-container delta="10" emptyResultsMessage="no-users-were-found">

This is the container. It performs a lot of set up work behind the scenes like instantiating the searchContainer object.

  • delta - The number of results per page
  • emptyResultsMessage - The message shown where there aren't results (it can be a key from your language.properties)

<liferay-ui:search-container-resultsresults="<%= UserLocalServiceUtil.search(company.getCompanyId(), searchTerms.getKeywords(), searchTerms.getActiveObj(), userParams, searchContainer.getStart(), searchContainer.getEnd(),searchContainer.getOrderByComparator()); %>"total="<%= UserLocalServiceUtil.searchCount(company.getCompanyId(), searchTerms.getKeywords(), searchTerms.getActiveObj(), userParams); %>" />

  • results - This is where you input the results. results should be of type List. The important part is to make sure that your method supports some way to search from a beginning index to an end index in order to provide a good performance pagination. Note how we use searchContainer.getStart() for the first index and searchContainer.getEnd() for the second index. As mentioned above, the searchContainer object is available because it has been instantiated already. Some other methods you can use:
    • searchContainer.getStart() - gets starting index of current results page.
    • searchContainer.getResultsEnd() - gets ending index of current results page or index of last result (i.e. will return 3 if delta is 5 but there are only 3 results).
    • searchContainer.getEnd() - gets last index of current results page regardless of size of actually results (i.e. will return 5 if delta is 5 even if there is only 3 results. Will throw out of bounds errors).
    • searchContainer.getCur() - gets number of current results page.
    • searchContainer.setTotal() - must be set so getResultsEnd() knows when to stop.
  • total - This is where you input the total number of items in your list:


<liferay-ui:search-container-row className="com.liferay.portal.model.User" keyProperty="userId" modelVar="user">

  • className - The type of Object in your List. In this case, we have a List of User objects.
  • keyProperty - Primary Key
  • modelVar - The name of the variable to represent your model. In this case the model is the User object.


<liferay-ui:search-container-column-text name="name" value="<%= user.getFullName() %>" />

  • <liferay-ui:search-container-column-text> - Text column
    • name - Name of the column
    • value - Value of the column
    • href - the text in this coulmn will be a link the this URL

    • orderable - allows the user to order the list of items by this column:


<liferay-ui:search-container-column-text name="first-name" property="firstName" />

  • property - This will automatically look in the User object for the "firstName" property. It's basically the same thing as user.getFirstName().

Important to note here; regardless of attribute capitalisation in your service.XML, the property value must always start lower case. After that it seems to follow what you defined.

<liferay-ui:search-iterator />

  • <liferay-ui:search-iterator /> - This is what actually iterates through and displays the List

Hopefully, this gives you a jump start on how to use Liferay's SearchContainer in your own portlets.


轉載于:https://my.oschina.net/aiguozhe/blog/70235

總結

以上是生活随笔為你收集整理的liferay-ui:search-container 用法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。