Foros de discusión

How to use reference in service builder in custom portlet?

thumbnail
delang j, modificado hace 7 años.

How to use reference in service builder in custom portlet?

Expert Mensajes: 252 Fecha de incorporación: 14/07/08 Mensajes recientes
hi guys, as per subject, do you have any idea how to use reference in custom portlet and how reference works.
like 'user' & 'contact' found in portal service.xml.

thanks
regrds,
delang
thumbnail
David H Nebinger, modificado hace 7 años.

RE: How to user reference in service builder in custom portlet?

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
Have you checked out the comments in the service builder dtd?






Come meet me at the NAS!
thumbnail
delang j, modificado hace 7 años.

RE: How to user reference in service builder in custom portlet?

Expert Mensajes: 252 Fecha de incorporación: 14/07/08 Mensajes recientes
thank you for your response,
i read that but somehow couldnt understand how to implement it.
maybe some example/sample portlet.

thank you
thumbnail
delang j, modificado hace 6 años.

RE: How to user reference in service builder in custom portlet?

Expert Mensajes: 252 Fecha de incorporación: 14/07/08 Mensajes recientes
my goal is to achieve something like this.
UserLocalServiceUtil.getUser(userId).getContact().getBirthday();

in custom service builder portlet.

tq
thumbnail
David H Nebinger, modificado hace 6 años.

RE: How to use reference in service builder in custom portlet?

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
Like the comment says, if you include a reference to the User entity, then SB will inject the UserLocalService into your XxxLocalServiceImpl. You'll be able to access it directly rather than going through the static utils.

Same kind of thing if you add a reference to the Contact entity, you'll get the ContactLocalService injected into your XxxLocalServiceImpl class.

There's no magic, there's no portlet even. You will just get the referenced services injected and you can use them in your XxxLocalServiceImpl to fetch the data from these other entities.
thumbnail
delang j, modificado hace 6 años.

RE: How to use reference in service builder in custom portlet?

Expert Mensajes: 252 Fecha de incorporación: 14/07/08 Mensajes recientes
thank you for your great explanation.

im not sure that im missed something or not, an error occurred before disappear after modified service.xml

below are service.xml
<entity name="Student" table="student" local-service="true" remote-service="false">
		<column name="studentId" type="long" primary="true" id-type="increment" />
		<column name="name" type="String" />
		<column name="addressId" type="String" />
		<column name="createdDate" type="Date" />
		<column name="modDate" type="Date" />

		<reference entity="Address" package-path="com.liferay.testsb" />
	</entity>
	<entity name="Address" table="address" local-service="true" remote-service="false">
		<column name="addressId" type="long" primary="true" id-type="increment" />
		<column name="street1" type="String" />
		<column name="street2" type="String" />
		<column name="street1" type="String" />
		<column name="city" type="String" />
		<column name="createdDate" type="Date" />
		<column name="modDate" type="Date" />
	</entity>


please advice.
thumbnail
David H Nebinger, modificado hace 6 años.

RE: How to use reference in service builder in custom portlet?

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
You only use reference for entities from a different service.xml, not entities in the same service.xml file.
thumbnail
Sushil Patidar, modificado hace 6 años.

RE: How to use reference in service builder in custom portlet?

Expert Mensajes: 467 Fecha de incorporación: 31/10/11 Mensajes recientes
Hi,

Address entity reference should be directly available as this entity is generated in the same module so i think you don't need to refer them in the same service builder.

Regards
thumbnail
Sushil Patidar, modificado hace 6 años.

RE: How to user reference in service builder in custom portlet?

Expert Mensajes: 467 Fecha de incorporación: 31/10/11 Mensajes recientes
Hi,

Liferay services can be referenced as documented here.Hope it helps.

Regards