留言板

Error in MVCPortlet class when following tutorial in liferay website

LR BEGINNER,修改在7 年前。

Error in MVCPortlet class when following tutorial in liferay website

New Member 帖子: 24 加入日期: 16-7-21 最近的帖子
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,修改在7 年前。

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

Liferay Legend 帖子: 14919 加入日期: 06-9-2 最近的帖子
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,修改在7 年前。

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

New Member 帖子: 24 加入日期: 16-7-21 最近的帖子
Hi David,

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