简体   繁体   中英

How can i wrap an existing liferay aui validator with a custom validator

I am looking to get more control over the validation process of liferay aui components so that i can put in some custom code to handle things such as error event tracking for web analytics. This question is related to my earlier question how can liferay alloy ui validation error be captured for web analytics? . After some more research i have discovered that custom javascript validators can be implemented using the aui:validator tag but what i would need is a way to delegate the validation to the original javascript handle, a kind of a super(); call so to speak. This would ensure that i would be able to leverage all the existing validation functionality existing within aui while being able to add my own logic for analytics.. Admittedly, this is not preferable as i would have to put in this logic in a lot of places in every JSP but at least i will have a solution for what essentially is a critical blocker for me right now.

I am keeping this as a separate question as this question is more pointed towards custom validations and a lot of people looking at this even for things other than web analytics would find this useful.

Looking forward to some guidance from the community...

I think is good idea to use a hook to make the validation what I mean is that:

Liferay is using some java class to make the validation you have to find this class and Override the methods used in there forthe validation(Best way to find the class is debugging). Here you can find an example . I have created my own hook so when liferay is adding new user in its own database to add the same user in mine but a little bit less information. You can play with the functionality :)

I hope this was helpful! Good luck!

Comment if you are stuck somewhere

I had some issues with Liferay 6.2 AUI custom validations. I've found out liferay is using AlloyUI 2.0 which has some bug in custom validation (especialy conditional validations). So I have created a custom formvalidator aui-form-validator-custom using fixes in AlloyUI 3.0.

Here you can see usage

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM