Foren
Liferay7 : Portlet developement, the new way
Armaz Mellati, geändert vor 7 Jahren.
Liferay7 : Portlet developement, the new way
Junior Member Beiträge: 96 Beitrittsdatum: 30.10.09 Neueste Beiträge
Hi
My goal is to create a sample portlet with its own Entities, the same way we used to get using the PluginSDK.
Following the documentation at https://dev.liferay.com/develop, I have managed to create the Workspace and the MVCPortlet. However it does not have any service.xml. It seems to me I am supposed to create another module using the "Servicebuilder" template.
Now I have done it, so I have a workspace with two Module projects. One mvcportlet and a Book-model (for instance), which consists of two sub-modules : an Book-api and a Book-service.
But how am I supposed to access the Book-Entitiy and services ? Have I missed some part of the documentation ?
PS! I try to use the Liferay IDE as much as possible.
My goal is to create a sample portlet with its own Entities, the same way we used to get using the PluginSDK.
Following the documentation at https://dev.liferay.com/develop, I have managed to create the Workspace and the MVCPortlet. However it does not have any service.xml. It seems to me I am supposed to create another module using the "Servicebuilder" template.
Now I have done it, so I have a workspace with two Module projects. One mvcportlet and a Book-model (for instance), which consists of two sub-modules : an Book-api and a Book-service.
But how am I supposed to access the Book-Entitiy and services ? Have I missed some part of the documentation ?
PS! I try to use the Liferay IDE as much as possible.
Gustavo Oliveira, geändert vor 7 Jahren.
RE: Liferay7 : Portlet developement, the new way (Antwort)
Junior Member Beiträge: 98 Beitrittsdatum: 23.09.15 Neueste Beiträge
You have to add the service module api as a depency on build.gradle.
Example:
And then use the Reference annotation to inject the service like this, the first one I created, the second is the native Counter:
Example:
compile project(":modules:persitencia:persitencia-api")
And then use the Reference annotation to inject the service like this, the first one I created, the second is the native Counter:
private TesteLocalService testeService;
private CounterLocalService counterService;
@Reference(unbind = "-")
public void setCounterService(CounterLocalService counterService) {
this.counterService = counterService;
}
@Reference(unbind = "-")
public void setTesteService(TesteLocalService testeService) {
this.testeService = testeService;
}
Armaz Mellati, geändert vor 7 Jahren.
RE: Liferay7 : Portlet developement, the new way
Junior Member Beiträge: 96 Beitrittsdatum: 30.10.09 Neueste Beiträge
Thanks alot. It did it.
However for the IDE to be able to compile, I had also to add the *-api project as a required project to the portlet-project. Otherwise the Eclipse shows a lot of errors.
However for the IDE to be able to compile, I had also to add the *-api project as a required project to the portlet-project. Otherwise the Eclipse shows a lot of errors.