留言板

Extending Service and Model

Kan Kon,修改在11 年前。

Extending Service and Model

New Member 帖子: 23 加入日期: 11-9-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.
Kan Kon,修改在11 年前。

RE: Extending Service and Model

New Member 帖子: 23 加入日期: 11-9-13 最近的帖子
I think expando is an option. But, like to hear from others on the forum as well.
thumbnail
David H Nebinger,修改在11 年前。

RE: Extending Service and Model

Liferay Legend 帖子: 14914 加入日期: 06-9-2 最近的帖子
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
Hitoshi Ozawa,修改在11 年前。

RE: Extending Service and Model

Liferay Legend 帖子: 7942 加入日期: 10-3-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).
Kan Kon,修改在11 年前。

RE: Extending Service and Model

New Member 帖子: 23 加入日期: 11-9-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
Hitoshi Ozawa,修改在11 年前。

RE: Extending Service and Model

Liferay Legend 帖子: 7942 加入日期: 10-3-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.