Forums de discussion

Interceptors in Liferay

thumbnail
MANOVINAYAK AYYAPPAN, modifié il y a 11 années.

Interceptors in Liferay

Regular Member Publications: 131 Date d'inscription: 13/06/11 Publications récentes
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, modifié il y a 11 années.

RE: Interceptors in Liferay

Junior Member Publications: 78 Date d'inscription: 30/11/11 Publications récentes
You can define servlet filters instead of interceptors. Also, If you are developing struts 2 portlets then interceptors can be used.
thumbnail
David H Nebinger, modifié il y a 11 années.

RE: Interceptors in Liferay

Liferay Legend Publications: 14916 Date d'inscription: 02/09/06 Publications récentes
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.