cancel
Showing results for 
Search instead for 
Did you mean: 

Custom action and contentService

liliandavy
Champ in-the-making
Champ in-the-making
Hi,

I try to develop a custom action, and I need to acces the content of a node from this action. So I try to use the content Service, butwhen I launch Alfresco, I have this error :
"17:04:40,500 ERROR [org.springframework.web.context.ContextLoader] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testPDF' defined in file [F:\Alfresco2.1\tomcat\shared\classes\alfresco\extension\testPDF-context.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'contentService' of bean class [testPDF.testPDFAction]: Bean property 'contentService' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?"

I suppose that it is possible to use the contentService from an action, I must be missing something.

My bean is declared like this :
<beans>
     
    <!– testPDF Action Bean –>
    <bean id="testPDF" class="testPDF.testPDFAction" parent="action-executer">
       <property name="nodeService">
            <ref bean="nodeService"></ref>
        </property>
        <property name="contentService">
            <ref bean="contentService" />
        </property>
   </bean>
      <!– Load the Logger Action Messages –>  
      <bean id="testPDF-action-messages" class="org.alfresco.i18n.ResourceBundleBootstrapComponent">
       <property name="resourceBundles">
          <list>
             <value>testPDF.testPDF-action-messages</value>
          </list>
       </property>
      </bean>
     
</beans>

public class generePDFAction extends ActionExecuterAbstractBase
{
    /** Mon logger */
    private static Log logger = LogFactory.getLog("org.alfresco.testPDF");
   
    private ContentService contentService;
   
    private NodeService nodeService;
    public void setNodeService(NodeService nodeService)
    {
      this.nodeService = nodeService;
   }   
   
    public void setContentService(ContentService contentService)
    {
        this.contentService = contentService;
    }
   
    @Override
    protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
    {
    //do some stuff
    }
1 REPLY 1

rivarola
Champ on-the-rise
Champ on-the-rise
Hello,

You should always inject a bean with first upper case in your own beans. The bean with first letter in upper case is the public one. The beans with first letter in lower case are private (and, in this case, not of the same type or abstract).
Your configuration should be :
<!– testPDF Action Bean –>
    <bean id="testPDF" class="testPDF.testPDFAction" parent="action-executer">
       <property name="nodeService">
            <ref bean="NodeService"/>
        </property>
        <property name="contentService">
            <ref bean="ContentService" />
        </property>
   </bean>