在liferay搜索容器中显示来自自定义查询(连接表)的数据

2023-12-31

我已关注这个维基 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(使用前将#替换为@)

在liferay搜索容器中显示来自自定义查询(连接表)的数据 的相关文章

随机推荐