留言板

Changes to user first and last name is not persistent...

thumbnail
Alain Dresse,修改在12 年前。

Changes to user first and last name is not persistent...

Junior Member 帖子: 95 加入日期: 11-7-18 最近的帖子
Hi,

I would like to share a tip that cost me a couple hours (and probably brought some white hair) this afternoon.

To update the firstname and the lastname of a user, you also (or maybe only ?) need to change the information on the contact.

In the following code:

Contact contact = user.getContact();
if(Validator.isNotNull(firstName)) {
	user.setFirstName(firstName);
	contact.setFirstName(firstName);
}
	
if(Validator.isNotNull(lastName)){
	user.setLastName(lastName);
	contact.setLastName(lastName);
}	
	
if(Validator.isNotNull(emailAddress)) {
	user.setEmailAddress(emailAddress);
}

UserLocalServiceUtil.updateUser(user);
ContactLocalServiceUtil.updateContact(contact);


Without the lase line of code (updateContact), the changes seem to be reflected, but the first and last name are reverted to the values before the change as soon as you switch languages...

Hope this will help someone,
Alain
Tibor Zimányi,修改在10 年前。

RE: Changes to user first and last name is not persistent...

New Member 发布: 1 加入日期: 13-8-2 最近的帖子
Hi,

thank you so much for this tip. This problem also cost me few hours, but your tip finally did the trick.

Tibor.
David Ilechukwu,修改在10 年前。

RE: Changes to user first and last name is not persistent...

Regular Member 帖子: 154 加入日期: 10-6-7 最近的帖子
Hey People -
What do you say to starting a "Develoment Tips & Tricks" pages on Wiki. This is quite typical for most CMS - serves a a good resource for both beginners and expos.
We certainly don't need more youngsters growing white hairs on problems that've been solved already.

Any votes?

Rgrds, David
thumbnail
James Falkner,修改在10 年前。

RE: Changes to user first and last name is not persistent...

Liferay Legend 帖子: 1399 加入日期: 10-9-17 最近的帖子
David Ilechukwu:
Hey People -
What do you say to starting a "Develoment Tips & Tricks" pages on Wiki. This is quite typical for most CMS - serves a a good resource for both beginners and expos.
We certainly don't need more youngsters growing white hairs on problems that've been solved already.

Any votes?

Rgrds, David


Hey David,

That's a great idea! I would love to see a definitive set of tips/tricks. There have been many people posting them on personal blogs (and and off liferay.com) and elsewhere, usually found via web searching, so our wiki page should have a section for external pointers as well. If you want to start the page, I'll volunteer to put as many external pointers as I know of into it emoticon
thumbnail
James Falkner,修改在10 年前。

RE: Changes to user first and last name is not persistent...

Liferay Legend 帖子: 1399 加入日期: 10-9-17 最近的帖子
David Ilechukwu:
Hey People -
What do you say to starting a "Develoment Tips & Tricks" pages on Wiki. This is quite typical for most CMS - serves a a good resource for both beginners and expos.
We certainly don't need more youngsters growing white hairs on problems that've been solved already.

Any votes?

Rgrds, David


BTW, there's also this (and it's pretty underwhelming emoticon ). The hardest part is keeping it up to date (that page could use some serious weeding). I'm exploring some other options for a knowledge base and easy way to find this stuff on our forums (including Liferay's own implementation), and would be interested in what others have found useful. For example, there are some cool features at StackOverflow that would be nice to have, both on liferay.com and in Liferay itself to make it easier to search/find answers, without having to have a big hierarchy or browse 15 levels deep to find what you want.