AnsweredAssumed Answered

Create a simple behavior sample - alfresco 3.4

Question asked by rantamplan2 on Mar 17, 2013
Latest reply on Mar 18, 2013 by rantamplan2
I am trying to implement a very simple behavior sample in my alfresco, but it doesn't install it ok, it appears in the log the message:

Invalid property 'nodeService' of bean class [jeffpotts.Invoicing]: Bean property 'nodeService' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?


My bean dmr-invoice-context.xml is:

<beans>
   <bean id="dmr_dani_sample_invoice_dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
      <property name="models">
         <list>
            <value>alfresco/extension/dmr-invoiceModel.xml</value>
         </list>
      </property>
   </bean>
   <bean id="ratingBehavior" class="jeffpotts.Invoicing" init-method="init">
        <property name="nodeService">
             <ref bean="NodeService" />
         </property>
         <property name="policyComponent">
             <ref bean="policyComponent"/>
         </property>
    </bean>
</beans>


This is my java class:

package jeffpotts;

import java.io.File;
import java.io.IOException;
import java.util.List;

import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.policy.Behaviour;
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;

public class Invoicing implements NodeServicePolicies.OnCreateNodePolicy
{
    private NodeService nodeService;
    private PolicyComponent policyComponent;
    private Behaviour onCreateNode;

    public void init()
    {
        this.onCreateNode = new JavaBehaviour(this, "onCreateNode", NotificationFrequency.TRANSACTION_COMMIT);
        QName qn1 = QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode");
       

        QName qn2 = QName.createQName(InvoiceModel.NAMESPACE_INVOICING_CONTENT_MODEL,
                InvoiceModel.TYPE_INVOICING.toString());

        this.policyComponent.bindClassBehaviour(qn1, qn2, this.onCreateNode);

    }

    @Override
    public void onCreateNode(ChildAssociationRef childAssocRef)
    {
        // Implement something

    }
}

Somebody can help me?. Thanks!

Outcomes