掲示板

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

thumbnail
12年前 に Alain Dresse によって更新されました。

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

Junior Member 投稿: 95 参加年月日: 11/07/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
10年前 に Tibor Zimányi によって更新されました。

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

New Member 投稿: 1 参加年月日: 13/08/02 最新の投稿
Hi,

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

Tibor.
10年前 に David Ilechukwu によって更新されました。

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

Regular Member 投稿: 154 参加年月日: 10/06/07 最新の投稿
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
10年前 に James Falkner によって更新されました。

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

Liferay Legend 投稿: 1399 参加年月日: 10/09/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
10年前 に James Falkner によって更新されました。

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

Liferay Legend 投稿: 1399 参加年月日: 10/09/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.