我已关注这个维基 http://www.liferay.com/community/wiki/-/wiki/Main/Custom+queries+in+Liferay+5.2并已成功构建自定义查询。
效果很好。我在表之间使用了联接。
我的问题是如何使用 liferay 搜索容器在 jsp 上显示它,因为搜索容器中的 className 需要一个模型类。
EDIT:
我看到name
, title
, status
and remarks
场都是String
(根据你的comment https://stackoverflow.com/questions/16683541/display-data-from-custom-queryjoined-tables-in-liferay-search-container/16718344#comment24017375_16683541)所以在for
循环你应该投Object
as a 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
然后返回该实体的列表,在您的情况下,我假设您有Student
and Attendance
实体,因此您可以将字段status
& remarks
in StudentImpl
然后返回一个List<Student>
or put fname
in AttendanceImpl
并返回List<Attendance>
从查找器方法。 (更新后这条评论 https://stackoverflow.com/questions/16683541/display-data-from-custom-queryjoined-tables-in-liferay-search-container#comment24087292_16718344)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)