Fórum

how to import service builder project in a portlet project

Alex Man, modificado 7 Anos atrás.

how to import service builder project in a portlet project

Junior Member Postagens: 70 Data de Entrada: 08/02/16 Postagens Recentes
I have one project which is having custom portlets and services (service.xml), the project is working fine but the thing is now we plan to separate in such a way one project holds all the custom portlets and the other holds all the services which includes the local and remote services. For to achieve that I have done the following:

Step 1: Created a portlet plugin projects named hse-portlet where I placed all the custom portlets.

Step 2: Created a service builder plugin projects named hse-service where I placed all the services.

Step 3: Build the hse-service project, created hse-service.jar and placed the jar under WEB-INF/lib in hse-portlet project.

Step 4: In one of my portlet when I wrote
HseCommitment hseCommitment = new HseCommitmentImpl();
, I have noticed that HseCommitmentImp class which is under com.hse.model.impl package is not importing and missing

when I observe in hse-service.jar which I have placed under WEB-INF/lib in hse-portlet project have no impl package like as shown below



Can anyone please tell me some solution to resolve this
thumbnail
David H Nebinger, modificado 7 Anos atrás.

RE: how to import service builder project in a portlet project

Liferay Legend Postagens: 14916 Data de Entrada: 02/09/06 Postagens Recentes
All access to the services should be done through the api.

Instead of trying to instantiate a concrete class which is not visible to you, you should be going through the api:

HseCommitment = HseCommitmentLocalServiceUtil.createHseCommitment(pkValue);
Alex Man, modificado 7 Anos atrás.

RE: how to import service builder project in a portlet project

Junior Member Postagens: 70 Data de Entrada: 08/02/16 Postagens Recentes
David H Nebinger:
All access to the services should be done through the api.

Instead of trying to instantiate a concrete class which is not visible to you, you should be going through the api:

HseCommitment = HseCommitmentLocalServiceUtil.createHseCommitment(pkValue);


So that means we wont be able to access all the classes which are under impl.
Lets say If we need to insert a new value for HseCommitment

Instead of doing

HseCommitment hseCommitment = new HseCommitmentImpl();
long  hseId = CounterLocalServiceUtil.increment(HseCommitment.class.getName());
hseCommitment.setId(hseId );
hseCommitment.setName("sample");
hseCommitment.setCreateddate(new Date());
HseCommitment newlyCreatedHSE = HseCommitmentLocalServiceUtil.addHseCommitment(hseCommitment);


I have to do

long  hseId = CounterLocalServiceUtil.increment(HseCommitment.class.getName());
HseCommitment hseCommitment = HseCommitmentLocalServiceUtil.createHseCommitment(hseId);
hseCommitment.setName("sample");
hseCommitment.setCreateddate(new Date());
HseCommitment newlyCreatedHSE = HseCommitmentLocalServiceUtil.addHseCommitment(hseCommitment);
thumbnail
David H Nebinger, modificado 7 Anos atrás.

RE: how to import service builder project in a portlet project (Resposta)

Liferay Legend Postagens: 14916 Data de Entrada: 02/09/06 Postagens Recentes
Exactly.

Even for your first example when they were merged, that was just wrong. Even then you should have been coding against the API and not the impl classes directly.