对列进行排序时 SearchContainer 未知 属性
SearchContainer unknown property while sorting columns
我有一个 view.jsp
的 portlet sampleimportlog_WAR_Testportlet
,我在其中显示 SampleImportLog
来自数据库查询的 searchContainer
实体。我得到结果
这是view.jsp
中的searchContainer
<liferay-ui:search-container emptyResultsMessage="sampleImportLog-empty-results-message" orderByType="<%= orderByType %>">
<%
List<SampleImportLog> allSampleImportLogs = SampleImportLogLocalServiceUtil.getSampleImportLogs(QueryUtil.ALL_POS, QueryUtil.ALL_POS);
List<SampleImportLog> sampleImportLogsPerPage = ListUtil.subList(allSampleImportLogs, searchContainer.getStart(),searchContainer.getEnd());
List<SampleImportLog> sortableSampleImportLogs = new ArrayList<SampleImportLog>(sampleImportLogsPerPage);
if(Validator.isNotNull(orderByCol)){
//Pass the column name to BeanComparator to get comparator object
BeanComparator comparator = new BeanComparator(orderByCol);
if(orderByType.equalsIgnoreCase("asc")){
//It will sort in ascending order
Collections.sort(sortableSampleImportLogs, comparator);
}else{
//It will sort in descending order
//Collections.reverse(sortableSampleImportLogs);
Collections.sort(sortableSampleImportLogs, Collections.reverseOrder(comparator));
}
}
searchContainer.setResults(sortableSampleImportLogs);
searchContainer.setTotal(SampleImportLogLocalServiceUtil.getSampleImportLogsCount());
%>
<liferay-ui:search-container-row
className="com.test.portlet.xxx.model.SampleImportLog"
keyProperty="importId"
modelVar="sampleImportLog" escapedModel="<%= true %>"
>
<portlet:renderURL var="viewSampleImportDetailsURL">
<portlet:param name="mvcPath" value="/html/sample/sampleimportlog/view_details.jsp" />
<portlet:param name="uuid" value="<%= sampleImportLog.getUuid() %>" />
</portlet:renderURL>
<portlet:actionURL name="deleteSampleImport" var="deleteSampleImportURL">
<portlet:param name="importId" value="<%= String.valueOf(sampleImportLog.getImportId()) %>" />
<portlet:param name="uuid" value="<%= String.valueOf(sampleImportLog.getUuid()) %>" />
</portlet:actionURL>
<liferay-ui:search-container-column-text
name="uuid"
property="uuid"
orderable="true"
orderableProperty="uuid"
href="<%= viewSampleImportDetailsURL %>"
/>
<liferay-ui:search-container-column-text
name="File Name"
property="fileName"
orderable="true"
orderableProperty="fileName"
href="<%= viewSampleImportDetailsURL %>"
/>
<liferay-ui:search-container-column-text
name="Imported By"
property="fullNameImporter"
orderable="true"
orderableProperty="fullNameImporter"
href="<%= viewSampleImportDetailsURL %>"
/>
<liferay-ui:search-container-column-text
name="Date Of Import"
property="dateOfImport"
orderable="true"
orderableProperty="dateOfImport"
href="<%= viewSampleImportDetailsURL %>"
/>
<liferay-ui:search-container-column-text>
<liferay-ui:icon-delete url="<%= deleteSampleImportURL.toString() %>"
message="<%= \"Delete this import\" %>"
confirmation="<%= \"Are you sure you want to delete this import? \" +
\"This will delete the import log as well as all the samples imported in this batch from the file \"
+ sampleImportLog.getFileName()+\".\" %>"
/>
</liferay-ui:search-container-column-text>
</liferay-ui:search-container-row>
<liferay-ui:search-iterator />
</liferay-ui:search-container>
当我点击行时,我得到 uuid (from the first column)
。使用此 uuid
,我查询另一个名为 Sample
的实体,并在另一个页面显示详细信息 view_details.jsp
。我可以在 view_details.jsp
中的 searchContainer 中类似地列出 sample entities
。到这里为止一切正常。
view_details.jsp
中的 searchContainer
看起来像这样
<liferay-ui:search-container emptyResultsMessage="sample-empty-results-message" orderByType="<%= orderByType %>" >
<%
List<Sample> samplesByuuid = SampleLocalServiceUtil.getSamplesByuuid(uuid);
List<Sample> samplesByuuidPerPage = ListUtil.subList(samplesByuuid, searchContainer.getStart(),searchContainer.getEnd());
List<Sample> sortableSamplesByuuid = new ArrayList<Sample>(samplesByuuidPerPage);
if(Validator.isNotNull(orderByCol)){
//Pass the column name to BeanComparator to get comparator object
BeanComparator comparator = new BeanComparator(orderByCol);
if(orderByType.equalsIgnoreCase("asc")){
//It will sort in ascending order
Collections.sort(sortableSamplesByuuid, comparator);
}else{
//It will sort in descending order
Collections.sort(sortableSamplesByuuid, Collections.reverseOrder(comparator));
}
}
searchContainer.setResults(sortableSamplesByuuid);
searchContainer.setTotal(samplesByuuid.size());
%>
<liferay-ui:search-container-row
className="com.test.portlet.xxx.model.Sample"
keyProperty="sampleDbId"
modelVar="sample" escapedModel="<%= true %>"
>
<liferay-ui:search-container-column-text
name="uuid_"
property="uuid_"
orderable="true"
orderableProperty="uuid_"
/>
<liferay-ui:search-container-column-text
name="container"
property="container"
orderable="true"
orderableProperty="container"
/>
...
...
</liferay-ui:search-container-row>
<liferay-ui:search-iterator />
</liferay-ui:search-container>
现在,当我单击其中一个 headers 对来自不同实体的 view_details.jsp
中的 searchContainer 中的结果进行排序时,我收到错误 Unknown property 'xxx' on class com.test.portlet.model.impl.SampleImportLogImpl'
.
我的理解是,portlet 绑定到一个实体 SampleImportLog
。我很想按 SampleImportLogImpl
中缺少的 属性 对 view_details.jsp
中的结果进行排序。但是,此 属性 存在于我在 view_details.jsp
.
中显示的实体 Sample
中
如何解决这个问题?我是否需要为来自不同实体的详细信息创建单独的 portlet?
我在 view.jsp
搜索容器中显示 SampleImportLog
个实体。单击一行后,我在 view_details.jsp
搜索容器中显示 Sample
个实体。在 view_details.jsp
中,当我尝试对搜索容器结果进行排序时,我在 class com.test.portlet.model.impl.SampleImportLogImpl 上收到错误 Unknown 属性 'xxx' 。
我发现我不需要为来自不同实体的详细信息创建单独的 portlet。该 portlet 未绑定到任何实体,我可以在 portlet jsp 中显示任何实体。
该错误是由于未能在 view_details.jsp
中维护搜索容器的上下文。因此,对搜索容器执行的任何操作都会导致导航到 Portlet 默认页面 view.jsp
。 view.jsp
搜索容器中显示的实体没有 属性,我试图根据它对 view_details.jsp
中的搜索容器进行排序。
所以为了在view_details.jsp
中维护搜索容器的上下文,我定义了
<liferay-portlet:renderURL varImpl="iteratorURL">
<portlet:param name="mvcPath" value="/html/sample/sampleimportlog/view_details.jsp" />
<portlet:param name="uuid" value="<%= uuid %>" />
</liferay-portlet:renderURL>
然后在searchContainer
中view_details.jsp
,我设置了iteratorURL
。
<liferay-ui:search-container emptyResultsMessage="sample-empty-results-message" orderByType="<%= orderByType %>" iteratorURL="<%=iteratorURL %>">
而且效果很好。现在我可以根据 view_details.jsp
.
中 Sample
实体的不同属性对搜索容器结果进行排序
我有一个 view.jsp
的 portlet sampleimportlog_WAR_Testportlet
,我在其中显示 SampleImportLog
来自数据库查询的 searchContainer
实体。我得到结果
这是view.jsp
searchContainer
<liferay-ui:search-container emptyResultsMessage="sampleImportLog-empty-results-message" orderByType="<%= orderByType %>">
<%
List<SampleImportLog> allSampleImportLogs = SampleImportLogLocalServiceUtil.getSampleImportLogs(QueryUtil.ALL_POS, QueryUtil.ALL_POS);
List<SampleImportLog> sampleImportLogsPerPage = ListUtil.subList(allSampleImportLogs, searchContainer.getStart(),searchContainer.getEnd());
List<SampleImportLog> sortableSampleImportLogs = new ArrayList<SampleImportLog>(sampleImportLogsPerPage);
if(Validator.isNotNull(orderByCol)){
//Pass the column name to BeanComparator to get comparator object
BeanComparator comparator = new BeanComparator(orderByCol);
if(orderByType.equalsIgnoreCase("asc")){
//It will sort in ascending order
Collections.sort(sortableSampleImportLogs, comparator);
}else{
//It will sort in descending order
//Collections.reverse(sortableSampleImportLogs);
Collections.sort(sortableSampleImportLogs, Collections.reverseOrder(comparator));
}
}
searchContainer.setResults(sortableSampleImportLogs);
searchContainer.setTotal(SampleImportLogLocalServiceUtil.getSampleImportLogsCount());
%>
<liferay-ui:search-container-row
className="com.test.portlet.xxx.model.SampleImportLog"
keyProperty="importId"
modelVar="sampleImportLog" escapedModel="<%= true %>"
>
<portlet:renderURL var="viewSampleImportDetailsURL">
<portlet:param name="mvcPath" value="/html/sample/sampleimportlog/view_details.jsp" />
<portlet:param name="uuid" value="<%= sampleImportLog.getUuid() %>" />
</portlet:renderURL>
<portlet:actionURL name="deleteSampleImport" var="deleteSampleImportURL">
<portlet:param name="importId" value="<%= String.valueOf(sampleImportLog.getImportId()) %>" />
<portlet:param name="uuid" value="<%= String.valueOf(sampleImportLog.getUuid()) %>" />
</portlet:actionURL>
<liferay-ui:search-container-column-text
name="uuid"
property="uuid"
orderable="true"
orderableProperty="uuid"
href="<%= viewSampleImportDetailsURL %>"
/>
<liferay-ui:search-container-column-text
name="File Name"
property="fileName"
orderable="true"
orderableProperty="fileName"
href="<%= viewSampleImportDetailsURL %>"
/>
<liferay-ui:search-container-column-text
name="Imported By"
property="fullNameImporter"
orderable="true"
orderableProperty="fullNameImporter"
href="<%= viewSampleImportDetailsURL %>"
/>
<liferay-ui:search-container-column-text
name="Date Of Import"
property="dateOfImport"
orderable="true"
orderableProperty="dateOfImport"
href="<%= viewSampleImportDetailsURL %>"
/>
<liferay-ui:search-container-column-text>
<liferay-ui:icon-delete url="<%= deleteSampleImportURL.toString() %>"
message="<%= \"Delete this import\" %>"
confirmation="<%= \"Are you sure you want to delete this import? \" +
\"This will delete the import log as well as all the samples imported in this batch from the file \"
+ sampleImportLog.getFileName()+\".\" %>"
/>
</liferay-ui:search-container-column-text>
</liferay-ui:search-container-row>
<liferay-ui:search-iterator />
</liferay-ui:search-container>
当我点击行时,我得到 uuid (from the first column)
。使用此 uuid
,我查询另一个名为 Sample
的实体,并在另一个页面显示详细信息 view_details.jsp
。我可以在 view_details.jsp
中的 searchContainer 中类似地列出 sample entities
。到这里为止一切正常。
view_details.jsp
中的 searchContainer
看起来像这样
<liferay-ui:search-container emptyResultsMessage="sample-empty-results-message" orderByType="<%= orderByType %>" >
<%
List<Sample> samplesByuuid = SampleLocalServiceUtil.getSamplesByuuid(uuid);
List<Sample> samplesByuuidPerPage = ListUtil.subList(samplesByuuid, searchContainer.getStart(),searchContainer.getEnd());
List<Sample> sortableSamplesByuuid = new ArrayList<Sample>(samplesByuuidPerPage);
if(Validator.isNotNull(orderByCol)){
//Pass the column name to BeanComparator to get comparator object
BeanComparator comparator = new BeanComparator(orderByCol);
if(orderByType.equalsIgnoreCase("asc")){
//It will sort in ascending order
Collections.sort(sortableSamplesByuuid, comparator);
}else{
//It will sort in descending order
Collections.sort(sortableSamplesByuuid, Collections.reverseOrder(comparator));
}
}
searchContainer.setResults(sortableSamplesByuuid);
searchContainer.setTotal(samplesByuuid.size());
%>
<liferay-ui:search-container-row
className="com.test.portlet.xxx.model.Sample"
keyProperty="sampleDbId"
modelVar="sample" escapedModel="<%= true %>"
>
<liferay-ui:search-container-column-text
name="uuid_"
property="uuid_"
orderable="true"
orderableProperty="uuid_"
/>
<liferay-ui:search-container-column-text
name="container"
property="container"
orderable="true"
orderableProperty="container"
/>
...
...
</liferay-ui:search-container-row>
<liferay-ui:search-iterator />
</liferay-ui:search-container>
现在,当我单击其中一个 headers 对来自不同实体的 view_details.jsp
中的 searchContainer 中的结果进行排序时,我收到错误 Unknown property 'xxx' on class com.test.portlet.model.impl.SampleImportLogImpl'
.
我的理解是,portlet 绑定到一个实体 SampleImportLog
。我很想按 SampleImportLogImpl
中缺少的 属性 对 view_details.jsp
中的结果进行排序。但是,此 属性 存在于我在 view_details.jsp
.
Sample
中
如何解决这个问题?我是否需要为来自不同实体的详细信息创建单独的 portlet?
我在 view.jsp
搜索容器中显示 SampleImportLog
个实体。单击一行后,我在 view_details.jsp
搜索容器中显示 Sample
个实体。在 view_details.jsp
中,当我尝试对搜索容器结果进行排序时,我在 class com.test.portlet.model.impl.SampleImportLogImpl 上收到错误 Unknown 属性 'xxx' 。
我发现我不需要为来自不同实体的详细信息创建单独的 portlet。该 portlet 未绑定到任何实体,我可以在 portlet jsp 中显示任何实体。
该错误是由于未能在 view_details.jsp
中维护搜索容器的上下文。因此,对搜索容器执行的任何操作都会导致导航到 Portlet 默认页面 view.jsp
。 view.jsp
搜索容器中显示的实体没有 属性,我试图根据它对 view_details.jsp
中的搜索容器进行排序。
所以为了在view_details.jsp
中维护搜索容器的上下文,我定义了
<liferay-portlet:renderURL varImpl="iteratorURL">
<portlet:param name="mvcPath" value="/html/sample/sampleimportlog/view_details.jsp" />
<portlet:param name="uuid" value="<%= uuid %>" />
</liferay-portlet:renderURL>
然后在searchContainer
中view_details.jsp
,我设置了iteratorURL
。
<liferay-ui:search-container emptyResultsMessage="sample-empty-results-message" orderByType="<%= orderByType %>" iteratorURL="<%=iteratorURL %>">
而且效果很好。现在我可以根据 view_details.jsp
.
Sample
实体的不同属性对搜索容器结果进行排序