掲示板

Extending Service and Model

11年前 に Kan Kon によって更新されました。

Extending Service and Model

New Member 投稿: 23 参加年月日: 11/09/13 最新の投稿
With reference to the new service hook in 6.1 (test-hook-portlet from plugins) which allows to override the service impl. Using the example code I could successfully override the service impl methods. However, I am wondering if it is possible to add few columns as well. The sample has a way to extend the model wrapper but need clues on how to persist the extended model. Any clues? Thanks in advance.
11年前 に Kan Kon によって更新されました。

RE: Extending Service and Model

New Member 投稿: 23 参加年月日: 11/09/13 最新の投稿
I think expando is an option. But, like to hear from others on the forum as well.
thumbnail
11年前 に David H Nebinger によって更新されました。

RE: Extending Service and Model

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
If you're adding one element (maybe two), expando would be the way to go. If you're adding a bunch of columns, it's better to externalize them to a separate table.

Some folks will tell you not to use expando at all (Hitoshi emoticon ), but in general I think it's an acceptable way to go.
thumbnail
11年前 に Hitoshi Ozawa によって更新されました。

RE: Extending Service and Model

Liferay Legend 投稿: 7942 参加年月日: 10/03/24 最新の投稿
If you use expando, you won't be able to extend the definition further in the future (i.e. you would only be able to add to the model and not inherit the model to create a new model). You'll be losing some modeling flexibility.
If you're just doing it for your own liferay implementation, it doesn't matter too much, but if you're creating an generic application (portlet) which you want to give users an options to extend on, expando isn't too good because your model and users' model will be mixed together and it would be very difficult to maintain. (liferay.com is trying to separate their codes with users' codes. This is in the same line - try not to get users' model and your model mixed).
11年前 に Kan Kon によって更新されました。

RE: Extending Service and Model

New Member 投稿: 23 参加年月日: 11/09/13 最新の投稿
Not sure if I understand you completely. Here, I am trying to extend the exiting model and my question was to understand a better approach to persist the additional attributes of the model. If you could refer to the "test-hook-portlet", it shows how to extend the service impl and model. I am trying to do the same and wondering how to persist additional model values. Thanks.
thumbnail
11年前 に Hitoshi Ozawa によって更新されました。

RE: Extending Service and Model

Liferay Legend 投稿: 7942 参加年月日: 10/03/24 最新の投稿
Yes, you'll doing it the "right" way. emoticon

I just re-read your original post. Sorry, I'm just replying to David's remark on using expando.