在XWiki中的#livetable宏中自定义过滤条件

下面这段文字是在#livetable的在线文档中的示例描述:参见。

Filter organizations by domain
The organization class in the example below has two properties: an org_name of type String and an org_domain of type StaticList. The organization domain can have values like Software or Hardware, which will be used in the live table as filter options.

#set($columns = ["org_name", "org_domain"])
#set($columnsProperties = {
    "org_name" : { "type" : "text" , "size" : 20, "link" : "view"},
    "org_domain" : { "type" : "list", "class": "MySpace.OrganizationClass"}
})

#set($options = {
  "resultPage":"MySpace.ListOrganizationJSON",
  "translationPrefix" : "",
  "rowCount": 10
})
#livetable("organization_directory" $columns $columnsProperties $options)
The content of MySpace.ListOrganizationJSON (using syntax 2.0):

{{include document="XWiki.LiveTableResultsMacros" /}}
{{velocity}}
#gridresultwithfilter("MySpace.OrganizationClass" $request.collist.split(",") "" " and doc.name<>'OrganizationSheet' and doc.name<>'OrganizationTemplate'")
{{/velocity}}

此示例感觉写得有点文不对题,实际上通常我们使用过滤时会根据实际对象(如例子中的OrganizationClass的文档中的对象)的属性进行过滤,比如现在有类:XWiki.DanJuSummaryClass,有属性version(字符串),需要表格展示所有version属性值为V7.0的文档出来怎么写过滤条件呢?

参考如下示例,在新建的页面中(如上面例子中的MySpace.ListOrganizationJSON页面)

{{include document="XWiki.LiveTableResultsMacros" /}}
{{velocity}}
#gridresultwithfilter("XWiki.DanJuSummaryClass" $request.collist.split(",") " ,StringProperty as sp" " and sp.name='version' and sp.value='V7.0' and obj.id=sp.id")
{{/velocity}}

SringProperty 是XWIKI中的所有字符串属性存储实体,最后一个条件obj.id=sp.id很重要,相当于SQL中的关联条件,没有这个条件过滤逻辑是不正确的,则结果也不正确。

XWiki安装使用技巧

Linux+Tomcat+XWiki+MySQL安装配置

XWiki 安装教程及更改语言配置

Windows下安装Java开源知识库XWiki 

XWiki 的详细介绍请点这里
XWiki 的下载地址请点这里

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/17374.html