フォーラム

ホーム » Liferay Portal » English » 3. Development

構造的に表示 平面上に表示 ツリー上に表示
スレッド [ 前へ | 次へ ]
Kan Kon
Extending Service and Model
2012/05/07 13:46
答え

Kan Kon

ランク: New Member

投稿: 23

参加年月日: 2011/09/12

最近の投稿

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
RE: Extending Service and Model
2012/05/07 15:00
答え

Kan Kon

ランク: New Member

投稿: 23

参加年月日: 2011/09/12

最近の投稿

I think expando is an option. But, like to hear from others on the forum as well.
David H Nebinger
RE: Extending Service and Model
2012/05/07 15:47
答え

David H Nebinger

Community Moderator

ランク: Liferay Legend

投稿: 8987

参加年月日: 2006/09/01

最近の投稿

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.
Hitoshi Ozawa
RE: Extending Service and Model
2012/05/07 17:41
答え

Hitoshi Ozawa

ランク: Liferay Legend

投稿: 7949

参加年月日: 2010/03/23

最近の投稿

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
RE: Extending Service and Model
2012/05/07 19:03
答え

Kan Kon

ランク: New Member

投稿: 23

参加年月日: 2011/09/12

最近の投稿

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.
Hitoshi Ozawa
RE: Extending Service and Model
2012/05/07 20:25
答え

Hitoshi Ozawa

ランク: Liferay Legend

投稿: 7949

参加年月日: 2010/03/23

最近の投稿

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.