我在 liferay Portal CE 6.2.0 上创建了一个带有工作流程的 portlet,并在部署后向其中添加了单个审批者工作流程。它工作成功,我可以查看通知、分配给某人并批准或拒绝。但是当我单击“查看”按钮时,它显示“未找到 Assets ”
<小时/>我不知道我错过了什么。我的代码中有以下内容。
在 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);
在资源渲染器中
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-portal/Portal-web/docroot/html/portlet/asset_publisher/view_content.jsp 在下面给定的代码点抛出的
if (!assetEntry.isVisible() &&
(assetRenderer.getAssetRendererType() == AssetRendererFactory.TYPE_LATEST_APPROVED)) {
throw new NoSuchModelException();
}
在这里我可以发现,即使我在 updateEntry 方法调用中将visible 设置为 true,它也会被设置为 false。我不知道该怎么办。问题出在哪里?
最佳答案
(将我的评论作为答案:)
AssetEntry 属于 Liferay 的架构,它使用 Service builder ORM 实现。如果您打开 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);
关于java - 无法在工作流程 liferay 中查看 Assets ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21308504/