Behaviour not works

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
v_scorsone
Member II

Behaviour not works

Hi, i've createad this model:

<?xml version="1.0" encoding="UTF-8"?>
<model xmlns="http://www.alfresco.org/model/dictionary/1.0" name="dmSmiley Very Happyemo">
    <author>Administrator</author>
    <imports>
        <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
        <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
    </imports>
    <namespaces>
        <namespace uri="http://www.mycom.it/model/demo/1.0" prefix="dm"/>
    </namespaces>
    <data-types/>
    <constraints/>
    <types>
        <type name="dm:demoTemplate">
            <title>Demo Template</title>
            <parent>cm:content</parent>
            <properties>
                <property name="dmSmiley Tonguelaceholder1">
                    <title>Placeholder 1</title>
                    <type>d:text</type>
                    <mandatory>false</mandatory>
                    <index enabled="true">
                        <tokenised>TRUE</tokenised>
                        <facetable>false</facetable>
                    </index>
                </property>
            </properties>
            <associations/>
            <overrides/>
            <mandatory-aspects/>
        </type>
    </types>
    <aspects/>
</model>

with the Model Manager of Alfresco 5.2.f.

I must implement a behaviour on update properties of demoTemplate.

In my init method i have:

QName MODEL_TEMPLATE_QNAME = QName.createQName("http//www.mycom.it/model/demo/1.0", "demoTemplate");

public void init() {
this.onUpdateProperties = new JavaBehaviour(this, "onUpdateProperties", NotificationFrequency.TRANSACTION_COMMIT);
this.policyComponent.bindClassBehaviour(NodeServicePolicies.OnUpdatePropertiesPolicy.QNAME, MODEL_TEMPLATE_QNAME, this.onUpdateProperties);
}

 when i add my amp to alfresco.war and restart the server, there is the error:

Caused by: java.lang.IllegalArgumentException: Class {http//www.mycom.it/model/demo/1.0}demoTemplate has not been defined in the data dictionary

how can i resolve this issue? i've read some post about this but i cant resolve. I have another question, there is a more "dynamic" way to do this without add the model.xml to my amp?

Thanks

3 Replies
jpotts
Advanced II

Re: Behaviour not works

Have you activated the model? Can you create instances of dm:demoTemplate when your behavior is not deployed?

Instead of using the model manager, if you add the model to your repo AMP and wire it in through Spring, does the problem go away?

v_scorsone
Member II

Re: Behaviour not works

Yes, i have activate the model and can create instances. I have also add the model in AMP, I did not have to?

jpotts
Advanced II

Re: Behaviour not works

If you defined the model in the UI you do not have to also define it in an AMP. You should use one or the other. If it is in your AMP but you already activated it in the UI, that could cause a problem.

Try removing it from the AMP, re-deploying your AMP, then restarting the server. If it still has a problem, reply here with your full stack trace.