Liferay App : Set Max Char Content

Liferay App : Set Max Char Content . This app provides facility to define max allowed character for structure element during web content creation.
In most of the cases, web contents are created with the help of structure and template.
To know more about Web contents in Liferay, please refer following blogs.

While creating Web content with structure and template, we can’t restrict user to enter data with specific length. In other word, out of the box, there is no such facility to restrict user to enter predefined number of characters for structure element. 

I have created new Liferay App which provides this facility. This free app is available on Liferay Marketplace (App name is Set Max Char to Content)

Liferay App :- Set Max Char

You can download this free app from liferay market place :- Set Max Char

Liferay App : Set Max Char Content - setMaxChar

This app is comprises of one liferay hook. After deploying this app, if we want to restrict user to add specific length of data then we need to set number of allowed characters in meta data (called ‘noOfCharacterAllowed‘) of structur’s element. 

For example, let say there is one element in structure called ‘component‘ and we want to set number of allowed characters to 100, then defined it in meta data as below

Liferay App : Set Max Char Content - define max allowed character

After defining number of allowed character in meta data, label like “Maximum 100 Characters are allowed” will be visible after each such element on web content creation screen as per below screenshot. 

Liferay App : Set Max Char Content - show max allowed characters

When user tries to save / publish web content, JS error message will be displayed for each such element where user had entered more than allowed characters as below screenshot

Liferay App : Set Max Char Content - max allowed characters validation

This way we can restrict number of allowed character dynamically and it is configurable through meta data.
Currently this feature is available to following types of elements

1. Text
2. Text-Box
3. Tex-Area(HTML)

For element of type Text-Area(HTML), the data will be stored in form of HTML. The No of character will be counted after filtering all html tags by this element, so it will count no of character which is actually entered by user.

So try this app and give your vote and (positive) feedback to me. Add any comments / questions / queries in Liferay Marketplace.(You need to create Liferay Marketplace account before putting comment).

I would recommend looking at index page ‘A Complete Liferay Guide‘ to browse all topics about liferay.

Share This Post

4 Comments - Write a Comment

Post Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.