Foren

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

thumbnail
Alain Dresse, geändert vor 12 Jahren.

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

Junior Member Beiträge: 95 Beitrittsdatum: 18.07.11 Neueste Beiträge
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, geändert vor 10 Jahren.

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

New Member Beitrag: 1 Beitrittsdatum: 02.08.13 Neueste Beiträge
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, geändert vor 10 Jahren.

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

Regular Member Beiträge: 154 Beitrittsdatum: 07.06.10 Neueste Beiträge
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, geändert vor 10 Jahren.

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

Liferay Legend Beiträge: 1399 Beitrittsdatum: 17.09.10 Neueste Beiträge
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, geändert vor 10 Jahren.

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

Liferay Legend Beiträge: 1399 Beitrittsdatum: 17.09.10 Neueste Beiträge
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.