歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> 在XWiki中的#livetable宏中自定義過濾條件

在XWiki中的#livetable宏中自定義過濾條件

日期:2017/2/28 14:26:54   编辑:Linux教程

下面這段文字是在#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安裝使用技巧 http://www.linuxidc.com/Linux/2014-10/108178.htm

Linux+Tomcat+XWiki+MySQL安裝配置 見 http://www.linuxidc.com/Linux/2013-11/93033.htm

XWiki 安裝教程及更改語言配置 http://www.linuxidc.com/Linux/2014-10/108173.htm

Windows下安裝Java開源知識庫XWiki http://www.linuxidc.com/Linux/2014-10/108176.htm

XWiki 的詳細介紹:請點這裡
XWiki 的下載地址:請點這裡

Copyright © Linux教程網 All Rights Reserved