Validation handler not deploying javascript in war

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

Validation handler not deploying javascript in war

Hello,

I am having a problem creating a custom validation handler in my alfresco. Whenever I start alfresco the war doesn't include my javascript file (test.js) that I placed inside the share project in the resources folder. When I try to use the form and the handler should come into action I get a error 404 saying that the resource test.js in not available. The path for my javascript file is: src/main/resources/js/test.js

share-custom-config.xml:

<config>
    <forms>
        <dependencies>
           <js src="/js/test.js"/>
        </dependencies>
    </forms>
</config>

 

<field id="dts:field1" >
          <constraint-handlers>
             <constraint type="MANDATORY" validation-handler="MyCustomNamespace.validateForm" event="keyup"/>
           </constraint-handlers>
</field>

test.js:

if (typeof MyCustomNamespace == "undefined" || !MyCustomNamespace) {
var MyCustomNamespace = {};
}

MyCustomNamespace.validateForm =
function validateForm(field, args, event, form, silent, message) {
...
}

Am I doing something wrong? I followed the documentation on the alfresco website:

Form Field Validation Handlers | Alfresco Documentation 

Thanks in advance for any help

regards

4 Replies
sanjaybandhniya
Intermediate

Re: Validation handler not deploying javascript in war

Try to use alfresco sdk for any customization.It will be easy to manage and deployment without affecting other process.

share-custom-config.xml : 

your code with custom handler and js file path.

your js file should be in /web/js/xxx.js

Thnaks,

Sanjay

gscorreia93
Member II

Re: Validation handler not deploying javascript in war

I managed to include the javascript file as you said. Thank you.

Now the problem is the validation function is never called whenever the event happens, although it is defined in the share-custom-config.xml. 

I have tried several setups with or without the type defined. But it never gets called...

Am I missing something?

Thanks in advance for any help,

regards

gscorreia93
Member II

Re: Validation handler not deploying javascript in war

Solved, thanks anyway. 

Can you tell me how to pass arguments for the validation function from the form?

Regards

sanjaybandhniya
Intermediate

Re: Validation handler not deploying javascript in war

Using this way,you will get value of current field.

if (typeof MyCustomNamespace == "undefined" || !MyCustomNamespace) {
var MyCustomNamespace = {};
}

MyCustomNamespace.validateForm =
function validateForm(field, args, event, form, silent, message) {
console.log(field.value);
}