掲示板

Interceptors in Liferay

thumbnail
11年前 に MANOVINAYAK AYYAPPAN によって更新されました。

Interceptors in Liferay

Regular Member 投稿: 131 参加年月日: 11/06/13 最新の投稿
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
11年前 に Subhash Shah によって更新されました。

RE: Interceptors in Liferay

Junior Member 投稿: 78 参加年月日: 11/11/30 最新の投稿
You can define servlet filters instead of interceptors. Also, If you are developing struts 2 portlets then interceptors can be used.
thumbnail
11年前 に David H Nebinger によって更新されました。

RE: Interceptors in Liferay

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
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.