2014-01-23 57 views
1

我在liferay portal CE 6.2.0上創建了一個帶有工作流程的portlet,並在部署後向其添加了單個審批者工作流程。它工作成功,我可以查看通知,分配給某人並批准或拒絕。但是,當我點擊查看按鈕,它說:「資產未找到」 enter image description here無法查看工作流程中的資產liferay


我想不出什麼我錯過了。我的代碼中有以下內容。

在LocalServiceImpl

assetEntryLocalService.updateEntry(userId, timesheet.getGroupId(), 
       date, date, Timesheet.class.getName(), 
       timesheet.getPrimaryKey(), timesheet.getUuid(), 0, 
       serviceContext.getAssetCategoryIds(), 
       serviceContext.getAssetTagNames(), true, null, null, null, 
       null, ContentTypes.TEXT_HTML, timesheet.getProject(), 
       timesheet.getTaskType(), timesheet.getProject() + " : " 
         + timesheet.getTaskType(), null, 0, 0, 0, false); 

在AssetRenderer

public String render(RenderRequest request, RenderResponse response, 
     String template) throws Exception { 
    if (template.equals("full_content")) { 
     request.setAttribute("TIMESHEET_ENTRY", _timesheet); 
     return "/html/" + template + ".jsp"; 
    } else { 
     return null; 
    } 
} 

在AssetRendererFactory

public AssetRenderer getAssetRenderer(long classPK, int type) 
     throws PortalException, SystemException { 
    Timesheet timesheet = TimesheetLocalServiceUtil.getTimesheet(classPK); 
    return new TimesheetAssetRenderer(timesheet); 
} 

這有什麼錯在我在做什麼?

我已經加入我的portlet.xml

 <asset-renderer-factory>com.timesheet.asset.TimesheetAssetRendererFactory</asset-renderer-factory> 

難道我需要重寫一些其他的功能,下面的?

我發現,錯誤是來自Liferay的門戶/門戶網站/文檔根目錄/ HTML /門戶/ asset_publisher/view_content.jsp在下面給出的代碼點

if (!assetEntry.isVisible() && 
      (assetRenderer.getAssetRendererType() == AssetRendererFactory.TYPE_LATEST_APPROVED)) { 

      throw new NoSuchModelException(); 
    } 

在這裏我能找到的拋出,即使如果我在updateEntry方法調用中將visible設置爲true,則它將被設置爲false。我不知道該怎麼做。問題在哪裏發生?

+0

日誌中的任何錯誤或消息? –

+0

沒有。控制檯中沒有錯誤。我能得到的只是UI中的這個錯誤。 – sree

+0

但我堅信我錯過了一些東西,因爲我只是接受了教程並且跟着他們,並且有很多錯誤主要由我自己解決。上述代碼是否需要添加爲資產? – sree

回答

0

(移植作爲一個答案:)

AssetEntry屬於使用服務構建器ORM落實Liferay的架構我的意見。如果你打開Liferay的源和搜索任何[SOME_MODEL_CLASS] LocalServiceImpl類,你可以看到更新型的功能如下這種模式:

SOME_MODEL_CLASS obj = sOME_MODEL_CLASSPersistence.findByPrimaryKey(longId); 
    obj.setSomeProperty(someValue); 
    sOME_MODEL_CLASSPersistence.update(obj, false); 

注意,在最後,他們正在呼叫的persistence.update,這將最終將更改存儲在數據庫中。

通常,更新Liferay對象的值時,一定要調用SOME_MODEL_CLASSLocalServiceUtil.update()函數。例如,在下面的代碼中,我試圖更新用戶的Facebook ID:

Contact cnt = user.getContact(); 
cnt.setFacebookSn(facebookId); 
ContactLocalServiceUtil.updateContact(cnt); 
UserLocalServiceUtil.updateUser(user); 
+0

請問您爲什麼(爲什麼使用)我們的* LocalServiceBaseImpl中有一個對象assetEntryLocalService或者它不是用戶? – sree

+0

我真的不明白這一點。你是什​​麼意思'是不是爲用戶' – yannicuLar

+0

等,你爲什麼使用LocalServiceBaseImpl而不是LocalServiceImpl? – yannicuLar