我有一個portlet嵌入到主題中。我發現允許主題從portlet獲取參數值的唯一解決方案是使用中間數據庫。 我所做的是我在portlet中創建一個表,然後我試圖從主題訪問該表:Liferay主題和portlet通信
的Java代碼在portlet:
ExpandoTable table=null;
try {
table = ExpandoTableLocalServiceUtil.addTable(CompanyLocalServiceUtil.getCompanies().get(0).getCompanyId(), User.class.getName(), "ClientTab");
}
catch ( DuplicateTableNameException dtne) {
table=ExpandoTableLocalServiceUtil.getTable(CompanyLocalServiceUtil.getCompanies().get(0).getCompanyId(), User.class.getName(), "ClientTab");
}
速度碼主題:
#set ($accountsTableName = "ClientTab")
#set ($accountsTable = $expandoTableLocalService.getTable($accountsTableName, $accountsTableName))
#if (!$accountsTable)
<h2> The table ClientTab doesn't exist </h2>
#else
<h2> Well The table ClientTab exists </h2>
#end
但結果是我得到的是:
ClientTab不存在表
我使用這些引用來開發我的代碼:
http://myjavaexp.blogspot.com/2013/01/liferay-expando-services.html
http://www.liferay.com/fr/web/raymond.auge/blog/-/blogs/715049
有沒有錯誤?你確定你不缺少參數:#set($ accountsTable = $ expandoTableLocalService.getTable($ accountsTableName,$ accountsTableName))'。另外爲什麼不顯示'$ accountsTable'來檢查。 –