留言板

save current user in service builder

Matt S.,修改在11 年前。

save current user in service builder

Junior Member 帖子: 36 加入日期: 12-11-29 最近的帖子
Hi all,

I have a problem with service builder, in particular i need to save the current user in it. I've created a string column in service builder and I use this code for saving current user...


User utente=PortalUtil.getUser(req);
String user=utente.getScreenName();
EventoLocalServiceUtil.addEvents(name, city, price, start_d,end_d, category, description,user);


At the beginning this code works, infact I can retrieve the current user name, but when I restart the server in place of user name appear SA.

How can I solve this problem?

Regards
thumbnail
Hitoshi Ozawa,修改在11 年前。

RE: save current user in service builder

Liferay Legend 帖子: 7942 加入日期: 10-3-24 最近的帖子
Not at all sure what you're doing. How are you using service builder? Did you create "Evento" service or modified liferay's user?
Where are putting this code?
Matt S.,修改在11 年前。

RE: save current user in service builder

Junior Member 帖子: 36 加入日期: 12-11-29 最近的帖子
Hi Hitoshi,

yes I've created a service bulder with entity called Evento where i put some column, like name city price, and a column called user of String type where I want save the current user name. Then I've created a class with logic to manipulate entity in which i've put the code posted by me. At the beginning works but when i restart the server it doesn't work, and instead of user name it retrieve me "SA". Where is the problem?
Matt S.,修改在11 年前。

RE: save current user in service builder

Junior Member 帖子: 36 加入日期: 12-11-29 最近的帖子
Please can you help me?
thumbnail
Sandeep Nair,修改在11 年前。

RE: save current user in service builder

Liferay Legend 帖子: 1744 加入日期: 08-11-6 最近的帖子
Is it possible for you to paste the code of eventolocalserviceimpl. I believe the problem may be that you might be using one of those methods that creates an entity but does not put in the database. Like there is a "createEntity" method which does not insert into database and there is "addEntity" method which creates and persists the value in db. I feel may be you are using the former method.

Regards,
Sandeep