Foros de discusión

Error in MVCPortlet class when following tutorial in liferay website

LR BEGINNER, modificado hace 7 años.

Error in MVCPortlet class when following tutorial in liferay website

New Member Mensajes: 24 Fecha de incorporación: 21/07/16 Mensajes recientes
Dear All,

I'm following the tutorial from Liferay website (https://dev.liferay.com/develop/tutorials/-/knowledge_base/6-2/updating-your-controller-to-use-services) and have error from the line below.
GuestbookLocalServiceUtil.addGuestbook(serviceContext.getUserId(), name, serviceContext);

It seems like it is pointed to GuestbookLocalServiceBaseImpl.public Guestbook addGuestbook(Guestbook guestbook), but there's actually method in GuestbookLocalServiceImpl.addGuestbook(long userId, String name, ServiceContext serviceContext)

Any help would be great. Thanks.
thumbnail
David H Nebinger, modificado hace 7 años.

RE: Error in MVCPortlet class when following tutorial in liferay website

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
Hi. You didn't report what the error actually was, but...

SB generates core methods automagically for the entity. You'll see those as createGuestbook(long), addGuestbook(Guestbook), deleteGuestbook(Guestbook), updateGuestbook(guestbook), etc.

Often times, however, this actually leaks business logic outside of the service layer. So as developers we will often add methods to the service that offer similarly named methods except use a simpler list of args so the business logic can remain inside the service layer.

The same has happened here - the addGuestbook() method that only requires the values needed to really add a new guestbook has been created that encapsulates the actual logic behind adding a new guestbook.

When you have a choice like this between the default method and an extension method with exploded params, always use the latter.







Come meet me at the LSNA!
LR BEGINNER, modificado hace 7 años.

RE: Error in MVCPortlet class when following tutorial in liferay website

New Member Mensajes: 24 Fecha de incorporación: 21/07/16 Mensajes recientes
Hi David,

Thanks for the reply. I found the issue and the resolution should be to rerun the build service for the service.xml.