Fórum

Extending Service and Model

Kan Kon, modificado 11 Anos atrás.

Extending Service and Model

New Member Postagens: 23 Data de Entrada: 13/09/11 Postagens Recentes
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, modificado 11 Anos atrás.

RE: Extending Service and Model

New Member Postagens: 23 Data de Entrada: 13/09/11 Postagens Recentes
I think expando is an option. But, like to hear from others on the forum as well.
thumbnail
David H Nebinger, modificado 11 Anos atrás.

RE: Extending Service and Model

Liferay Legend Postagens: 14919 Data de Entrada: 02/09/06 Postagens Recentes
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, modificado 11 Anos atrás.

RE: Extending Service and Model

Liferay Legend Postagens: 7942 Data de Entrada: 24/03/10 Postagens Recentes
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, modificado 11 Anos atrás.

RE: Extending Service and Model

New Member Postagens: 23 Data de Entrada: 13/09/11 Postagens Recentes
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, modificado 11 Anos atrás.

RE: Extending Service and Model

Liferay Legend Postagens: 7942 Data de Entrada: 24/03/10 Postagens Recentes
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.