如何获取Alfresco ContentService对象?

如何获取Alfresco ContentService对象?,alfresco,Alfresco,我试图在露天阅读文件的内容。我看到过使用 内容服务。不幸的是,当我尝试使用示例代码时,ContentService 没有。 我在faces-config.xml中添加了ContentService作为托管bean的托管属性 <managed-property> <property-name>contentService</property-name> <value>#{ContentService}</value> </manag

我试图在露天阅读文件的内容。我看到过使用 内容服务。不幸的是,当我尝试使用示例代码时,ContentService 没有。 我在faces-config.xml中添加了ContentService作为托管bean的托管属性

<managed-property>
<property-name>contentService</property-name>
<value>#{ContentService}</value>
</managed-property>
我得到一个例外:

javax.faces.el.EvaluationException:调用表达式#{deployAssetQadiolog.start}时发生异常 原因: javax.faces.el.PropertyNotFoundException:Bean:com.xxxxxxxxx.cccc.DeployAssetDialog,属性:contentService


有人能告诉我我是否遗漏了什么吗?谢谢

PropertyNotFoundException
听起来您的托管bean缺少setter方法

如何向jsf公开spring托管bean可能取决于您使用的spring和/或jsf版本。请看一个例子

最后,确保在jsf启动之前初始化了Alfresco spring上下文

代码中的许多问题

1) 对于注入的每个服务,您需要为它们添加getter setter方法。 如果为contentservice添加getter setter,则可以消除错误


2) 另一件事是您正试图通过服务注册中心获取conentservice,在这种情况下,您需要注入服务注册中心并为此添加getter setter。否则,直接获取contentservice实例,因为它是通过faces config注入的,并且如果您为它添加了getter setter,那么您可以直接使用该contentservice实例。

我建议您使用spring上下文文件连接
contentservice
(请注意,大C-您几乎总是需要大字母bean)到您自己的bean,或者从活动服务注册表中获取它,而不是让faces做奇怪的事情……您能提供到示例代码的链接吗?我还没有看到任何重写faces-config.xml的代码。就像@Gagravarr说的使用弹簧!
ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
final ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);

// contentService is an instance variable.
this.contentService = serviceRegistry.getContentService();