Foren

Error in MVCPortlet class when following tutorial in liferay website

LR BEGINNER, geändert vor 7 Jahren.

Error in MVCPortlet class when following tutorial in liferay website

New Member Beiträge: 24 Beitrittsdatum: 21.07.16 Neueste Beiträge
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, geändert vor 7 Jahren.

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

Liferay Legend Beiträge: 14916 Beitrittsdatum: 02.09.06 Neueste Beiträge
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, geändert vor 7 Jahren.

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

New Member Beiträge: 24 Beitrittsdatum: 21.07.16 Neueste Beiträge
Hi David,

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