Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Matt S.
save current user in service builder
March 4, 2013 12:21 PM
Answer

Matt S.

Rank: Junior Member

Posts: 36

Join Date: November 29, 2012

Recent Posts

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...

1
2User utente=PortalUtil.getUser(req);
3String user=utente.getScreenName();
4EventoLocalServiceUtil.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
Hitoshi Ozawa
RE: save current user in service builder
March 4, 2013 2:10 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7952

Join Date: March 23, 2010

Recent Posts

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.
RE: save current user in service builder
March 5, 2013 1:46 AM
Answer

Matt S.

Rank: Junior Member

Posts: 36

Join Date: November 29, 2012

Recent Posts

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.
RE: save current user in service builder
March 7, 2013 7:29 AM
Answer

Matt S.

Rank: Junior Member

Posts: 36

Join Date: November 29, 2012

Recent Posts

Please can you help me?
Sandeep Nair
RE: save current user in service builder
March 7, 2013 7:46 AM
Answer

Sandeep Nair

Rank: Liferay Legend

Posts: 1693

Join Date: November 5, 2008

Recent Posts

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