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
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
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
Solved, thanks anyway.
Can you tell me how to pass arguments for the validation function from the form?
Regards
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);
}
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.