mysql – 在liferay搜索容器中显示Custom Query(Joined tables)中的数据
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了mysql – 在liferay搜索容器中显示Custom Query(Joined tables)中的数据,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2774字,纯文字阅读大概需要4分钟。
内容图文
我已经按照this wiki并成功构建了自定义查询.
它工作正常.我在表之间使用了连接.
我的问题是如何使用liferay搜索容器在jsp上显示它,因为搜索容器中的className需要一个模型类.
编辑:
我到现在为止尝试的是:
<%
getAttendanceData attName = new getAttendanceData();
List<Object[]> displayAttListName = AttendanceLocalServiceUtil.findAttendance();
ArrayList name = new ArrayList();
ArrayList title = new ArrayList();
ArrayList status = new ArrayList();
ArrayList remarks = new ArrayList();
for(Object[] att:displayAttListName) {
name.add(att[0]);
title.add(att[1]);
status.add(att[2]);
remarks.add(att[3]);
}
%>
<liferay-ui:search-container delta="20" emptyResultsMessage="No Results Found">
<liferay-ui:search-container-results
total="<%= displayAttListName.size() %>"
results="<%= ListUtil.subList(displayAttListName , searchContainer.getStart(), searchContainer.getEnd()) %>"
/>
<liferay-ui:search-container-row modelVar="search"
className="java.lang.Object">
<%
for(Object displayName:name) {
%>
<liferay-ui:search-container-column-text name='studName' value = '<%=String.valueOf(displayName)%>' href="">
</liferay-ui:search-container-column-text>
<%
}
%>
</liferay-ui:search-container-row>
<liferay-ui:search-iterator/>
</liferay-ui:search-container>
我上面所做的就是在一列中10次显示10个名字.
我希望名称出现在每个新行上.我怎么修改上面的代码?
编辑2
考虑到之前定义的name数组,我做了以下内容:
<liferay-ui:search-container-column-text name="employee name" href = "">
<%=name.getClass().getDeclaredFields().toString() %>
</liferay-ui:search-container-column-text>
有了上面的内容,我得到的结果如下:[Ljava.lang.reflect.Field;每行@ 195f1af.
解决方法:
我看到名称,标题,状态和备注字段都是String(根据你的comment)所以在for循环中你应该将Object转换为String,你不需要四个ArrayList.
以下是行标记的外观:
<liferay-ui:search-container-row className="java.lang.Object" modelVar="search">
<%--
Since an "Object[]" is nothing but an "Object", we first cast the "search"
instance to an "Object[]" and then to a "String"
--%>
<liferay-ui:search-container-column-text name='name' value='<%= (String) ((Object[])search)[0] %>' />
<liferay-ui:search-container-column-text name='title' value='<%= (String) ((Object[])search)[1] %>' />
<liferay-ui:search-container-column-text name='status' value='<%= (String) ((Object[])search)[2] %>' />
<liferay-ui:search-container-column-text name='remarks' value='<%= (String) ((Object[])search)[3] %>' />
</liferay-ui:search-container-row>
你去,这应该工作.
我认为更清洁的方法是定义一个POJO来存储这些值,然后返回POJO的列表.我没有尝试过第二种方法.
另一种标准方法是在实体的任何一个* Impl中包含额外的字段,然后返回该实体的列表,在您的情况下,我假设您有学生和出勤实体,因此您可以将字段状态和放置.在StudentImpl中备注然后返回List< Student>或者将fname放入AttendanceImpl并返回List< Attendance>从finder方法. (this comment之后更新)
内容总结
以上是互联网集市为您收集整理的mysql – 在liferay搜索容器中显示Custom Query(Joined tables)中的数据全部内容,希望文章能够帮你解决mysql – 在liferay搜索容器中显示Custom Query(Joined tables)中的数据所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。