Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
MANOVINAYAK AYYAPPAN
Interceptors in Liferay
August 30, 2012 4:56 AM
Answer

MANOVINAYAK AYYAPPAN

Rank: Regular Member

Posts: 132

Join Date: June 13, 2011

Recent Posts

Hi All,

This is regarding Server Side Validation in Liferay:

These are the steps that I follow for server side validation (After When the User submits the form by clicking the submit button):
In portlet Class
1. Get all the attributes from Request.
2. Pass these attributes to a Util Method where I do all the Validations (Server Side Validation)
3. If All the Validation are fine then I call the corresponding LocalServices to persist to database.

Additionally I tend to use the Custom Exceptions declared by me in the Service.xml, this I use it at the Service Level.

But I feel this is a kind of rigid and non-extensible method of Validation.

Prior to working in Liferay I used to work in Struts 2 where we had the privilege of using INTERCEPTOR, which I feel is quite extensible and maintainable.

I would like to know whether is there some kind of Interceptor available in Liferay for this purpose.
Else please share your best practice for this purpose.

Regards,
Mano
Subhash Shah
RE: Interceptors in Liferay
August 30, 2012 6:26 AM
Answer

Subhash Shah

Rank: Junior Member

Posts: 77

Join Date: November 29, 2011

Recent Posts

You can define servlet filters instead of interceptors. Also, If you are developing struts 2 portlets then interceptors can be used.
David H Nebinger
RE: Interceptors in Liferay
August 30, 2012 12:40 PM
Answer

David H Nebinger

Community Moderator

Rank: Liferay Legend

Posts: 11295

Join Date: September 1, 2006

Recent Posts

MANOVINAYAK AYYAPPAN:
I would like to know whether is there some kind of Interceptor available in Liferay for this purpose.


No, and nor should there be.

Data validation is a task for pieces farther up in the MVC layers of a project. You should never be in a position where you need to scrub/validate data in the DAO layer (which the ServiceBuilder stuff represents).

If you move your validation to MVC, you have lots of alternatives including spring validation, javascript validation, etc.