Foren

How to display account user's Prefix like(Mr,Ms,Dr,Mrs) in a portlet?

thumbnail
raghuraman mg, geändert vor 15 Jahren.

How to display account user's Prefix like(Mr,Ms,Dr,Mrs) in a portlet?

New Member Beiträge: 12 Beitrittsdatum: 16.12.08 Neueste Beiträge
i.e To display account user's Prefix like(Mr,Ms,Dr,Mrs) in a portlet, Which class and method we have to use.
thumbnail
Amos Fong, geändert vor 15 Jahren.

RE: How to display account user's Prefix like(Mr,Ms,Dr,Mrs)

Liferay Legend Beiträge: 2047 Beitrittsdatum: 07.10.08 Neueste Beiträge
Looks like you need to get the user object using userlocalserviceutil, then get the contact object which contains the prefixid.
thumbnail
Luc Pons, geändert vor 15 Jahren.

RE: How to display account user's Prefix like(Mr,Ms,Dr,Mrs)

Junior Member Beiträge: 70 Beitrittsdatum: 03.12.08 Neueste Beiträge
and what would be the difference between the prefixId and the suffixId ??
Which one do we want to use as a key ?

Luc
thumbnail
Amos Fong, geändert vor 15 Jahren.

RE: How to display account user's Prefix like(Mr,Ms,Dr,Mrs)

Liferay Legend Beiträge: 2047 Beitrittsdatum: 07.10.08 Neueste Beiträge
I'm not sure if I understand your question, but prefixes are Mr., Dr., Mrs., etc. Suffixes are Sr., Jr., III, etc.
Sarfarajali Kadiwala, geändert vor 12 Jahren.

RE: How to display account user's Prefix like(Mr,Ms,Dr,Mrs)

New Member Beiträge: 12 Beitrittsdatum: 18.09.10 Neueste Beiträge
hi we are using liferay 6.0,
i need the same but bit different i want to display user's with prefix but not doing any change in each portlet individually.
suppose in blogs, blogs aggregato, asset publisher etc there is By userxyzname but i want here By Dr/Mr/Mrs userxyzname.
so is there any centralized configuration like in portal.propaties or anywhere else.

thanks.
thumbnail
Rojalin Patri, geändert vor 12 Jahren.

RE: How to display account user's Prefix like(Mr,Ms,Dr,Mrs)

Expert Beiträge: 287 Beitrittsdatum: 22.03.11 Neueste Beiträge
Hi all,
Yes, Amos has given a clear distinction . I've implemented the the same in the following way.
ListType listType=ListTypeServiceUtil.getListType(contact.getPrefixId());
String prefix =listType.getName();

you just have to access the contact object somehow in your view.jsp page or on whatever page you wish to display this.
or else you have to get the user object from which you can also get the prefix id like this user.getContact().getPrefixId()
Hope this helps...
Regards
Rojalin
Sarfarajali Kadiwala, geändert vor 12 Jahren.

RE: How to display account user's Prefix like(Mr,Ms,Dr,Mrs)

New Member Beiträge: 12 Beitrittsdatum: 18.09.10 Neueste Beiträge
Thanks a lot dear for quick reply.
But according to your solution i have to make changes in all related jsps wherever i want to display user name with prefix. And i do not want so.
Is there any way in which i change at only one place and all portlets will be get affected. like in portal.properties or any where else.

Thanks.
thumbnail
Hitoshi Ozawa, geändert vor 12 Jahren.

RE: How to display account user's Prefix like(Mr,Ms,Dr,Mrs)

Liferay Legend Beiträge: 7942 Beitrittsdatum: 24.03.10 Neueste Beiträge
Sorry, not without modifying Liferay's source code. It's possible to modify Liferay's User model to add prefix to FullName, but this will add prefix to every occurence where FullName is used.
thumbnail
Rojalin Patri, geändert vor 12 Jahren.

RE: How to display account user's Prefix like(Mr,Ms,Dr,Mrs)

Expert Beiträge: 287 Beitrittsdatum: 22.03.11 Neueste Beiträge
i don't think so Sarf...this is the java function which has to be placed in your jsp...as far as i know..it's not possible in portal.properties.because portlets are a kind of independent applications which are put into a container called portal.i am not sure whether we can set it globally..
may be some other experts can give us a better idea...
Sarfarajali Kadiwala, geändert vor 12 Jahren.

RE: How to display account user's Prefix like(Mr,Ms,Dr,Mrs)

New Member Beiträge: 12 Beitrittsdatum: 18.09.10 Neueste Beiträge
thanks bro. no problem.
Sarfarajali Kadiwala, geändert vor 12 Jahren.

RE: How to display account user's Prefix like(Mr,Ms,Dr,Mrs)

New Member Beiträge: 12 Beitrittsdatum: 18.09.10 Neueste Beiträge
hi Rojalin Patri,

ListType listType=ListTypeServiceUtil.getListType(contact.getPrefixId());
String prefix =listType.getName();


k now i am doing according to your suggestion but i found that in contact table there is prefixId field but there is no value, all records have zero value.
so why prefixId is not stored in that field.
now how can i get prefixId and what should i do to get Stored prefixId in that field.

thanks.
thumbnail
Rojalin Patri, geändert vor 12 Jahren.

RE: How to display account user's Prefix like(Mr,Ms,Dr,Mrs)

Expert Beiträge: 287 Beitrittsdatum: 22.03.11 Neueste Beiträge
Hi Sarf,
i forgot to mention that it gives "No ListType exists with the primary key 0” exception.error when the prefixId is Null as contact.getPrefixId() returns 0.So you have to handle the exception for the users who don't have a prefixId . For testing the same, log in to the portal as Admin(Bruno or test@liferay.com) ,create a new user in control panel with a prefix or title and then try to log in to the portal with that new user credentials.You should get the prefixes "Mr/Mrs/Dr" in your portlet.
Regards
Rojalin
Sarfarajali Kadiwala, geändert vor 12 Jahren.

RE: How to display account user's Prefix like(Mr,Ms,Dr,Mrs)

New Member Beiträge: 12 Beitrittsdatum: 18.09.10 Neueste Beiträge
thank u Rojalin patri, yes its a situation where u will get exception but my problem was different, when i edit user and save its prefix still it was saving zero, then i replaced my tomcat now its saving prefix id.
thnaks again for reply.