掲示板

Error in MVCPortlet class when following tutorial in liferay website

7年前 に LR BEGINNER によって更新されました。

Error in MVCPortlet class when following tutorial in liferay website

New Member 投稿: 24 参加年月日: 16/07/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
7年前 に David H Nebinger によって更新されました。

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

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
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!
7年前 に LR BEGINNER によって更新されました。

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

New Member 投稿: 24 参加年月日: 16/07/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.