0

I am attempting to read the content of a file in Alfresco. I have seen examples that use ContentService. Unforunately, when I try to use the example code, the ContentService is not available. I have added ContentService as a managed property of my managed bean in faces-config.xml

<managed-property>
<property-name>contentService</property-name>
<value>#{ContentService}</value>
</managed-property>

In my java code, I am using

ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
final ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);

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

I am getting this Exception:

javax.faces.el.EvaluationException: Exception while invoking expression #{DeployAssetQADialog.start} caused by: javax.faces.el.PropertyNotFoundException: Bean: com.XXXXXXXXXX.CCCCCCCC.DeployAssetDialog, property: contentService

Can anyone tell me if there is something that I am missing? Thanks

  • I'd suggest you either use a spring context file to wire the `ContentService` (note big C - you almost always want big letter beans) to your own bean, or grab it off an active Service Registry, rather than asking faces to do strange things... – Gagravarr Mar 01 '14 at 09:17
  • Can you provide a link to the example code? I haven't really seen any code which overrides the faces-config.xml. Like @Gagravarr says use Spring! – Tahir Malik Mar 03 '14 at 09:47

2 Answers2

1

PropertyNotFoundException sounds like your managed bean is missing a setter method.

How to expose spring managed beans to jsf may depend on the spring and/or jsf version you are using. Have a look at Spring beans injected into JSF Managed Beans for an example.

Finally, Make sure your Alfresco spring context is initialized before jsf kicks in.

Community
  • 1
  • 1
Andreas Steffan
  • 6,039
  • 2
  • 23
  • 25
0

Many issues in code

1) For each services which are injected you need to add getter setter method for them. If you add getter setter for contentservice you can get rid of your error.

2) Other thing is you are trying to get conentservice though service registry in that case you need to inject service registry and add getter setter for that. Otherwise get contentservice instance directly as it is injected though faces-config and provided you have added getter setter for it you can directly use that instance of contentservice.

mitpatoliya
  • 2,037
  • 12
  • 23