Message Boards

Liferay 7 - configuration to deploy alternative ScreenNameValidator

Alan Dunk, modified 7 Years ago.

Liferay 7 - configuration to deploy alternative ScreenNameValidator

New Member Posts: 5 Join Date: 6/6/16 Recent Posts
Hi,

I've got the Tomcat bundle of Liferay 7 installed, looks like good work!

I want to change the configuration a little, I'm still finding my way around Liferay 7 and wish to understand how this works.

So the install is configured to use Screen Name validation already, I've got that working, and can see DefaultScreenNameValidator is the class which is doing the work.

How does the Portal know to use DefaultScreenNameValidator? In Liferay 6.2 it is possible to configure by using
users.screen.name.validator
in portal-ext.properties to change the validator, either to use LiberalScreenNameValidator or a custom one.. The customisation seems to have changed in Liferay 7, as the comment in portal.properties from the Portal implementation tells me this is no longer used by the portal.

At the code level, is it configured by a Hook? I noticed that the Hook deployer does look for this property and register the class as the validator if it is found. Can see that ScreenNameValidatorFactory gets the validator from the OSGi service, which is just a class that implements the ScreenNameValidator interface, so can be done, I'm just struggling to see where the DefaultScreenNameValidator implementation is actually registered for use?

TIA.
thumbnail
Romeo Sheshi, modified 7 Years ago.

RE: Liferay 7 - configuration to deploy alternative ScreenNameValidator (Answer)

Junior Member Posts: 35 Join Date: 5/9/12 Recent Posts
Hi,

the osgi service use the ranking properties to pick up the implementation. so if you want to use Liberal i think you can do this way


@Component(
        immediate = true,
        property = {"service.ranking:Integer=10"},
        service = ScreenNameValidator.class

)
public class MyScreenNameValidator extends LiberalScreenNameValidator{}


if you want to create an custom validator can see the blade examples blade.screenname.validator
Alan Dunk, modified 7 Years ago.

RE: Liferay 7 - configuration to deploy alternative ScreenNameValidator

New Member Posts: 5 Join Date: 6/6/16 Recent Posts
Great, I configured to use the Blades example which works. emoticon