Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
raghuraman mg
How to display account user's Prefix like(Mr,Ms,Dr,Mrs) in a portlet?
January 27, 2009 4:36 AM
Answer

raghuraman mg

Rank: New Member

Posts: 12

Join Date: December 16, 2008

Recent Posts

i.e To display account user's Prefix like(Mr,Ms,Dr,Mrs) in a portlet, Which class and method we have to use.
Amos Fong
RE: How to display account user's Prefix like(Mr,Ms,Dr,Mrs)
February 5, 2009 5:55 PM
Answer

Amos Fong

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1844

Join Date: October 7, 2008

Recent Posts

Looks like you need to get the user object using userlocalserviceutil, then get the contact object which contains the prefixid.
Luc Pons
RE: How to display account user's Prefix like(Mr,Ms,Dr,Mrs)
March 25, 2009 8:15 AM
Answer

Luc Pons

Rank: Junior Member

Posts: 70

Join Date: December 3, 2008

Recent Posts

and what would be the difference between the prefixId and the suffixId ??
Which one do we want to use as a key ?

Luc
Amos Fong
RE: How to display account user's Prefix like(Mr,Ms,Dr,Mrs)
March 26, 2009 9:31 AM
Answer

Amos Fong

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1844

Join Date: October 7, 2008

Recent Posts

I'm not sure if I understand your question, but prefixes are Mr., Dr., Mrs., etc. Suffixes are Sr., Jr., III, etc.
Sarfarajali Kadiwala
RE: How to display account user's Prefix like(Mr,Ms,Dr,Mrs)
March 13, 2012 1:15 AM
Answer

Sarfarajali Kadiwala

Rank: New Member

Posts: 12

Join Date: September 17, 2010

Recent Posts

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.
Rojalin Patri
RE: How to display account user's Prefix like(Mr,Ms,Dr,Mrs)
March 13, 2012 2:09 AM
Answer

Rojalin Patri

Rank: Expert

Posts: 287

Join Date: March 22, 2011

Recent Posts

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
RE: How to display account user's Prefix like(Mr,Ms,Dr,Mrs)
March 13, 2012 5:08 AM
Answer

Sarfarajali Kadiwala

Rank: New Member

Posts: 12

Join Date: September 17, 2010

Recent Posts

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.
Hitoshi Ozawa
RE: How to display account user's Prefix like(Mr,Ms,Dr,Mrs)
March 13, 2012 5:49 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7954

Join Date: March 23, 2010

Recent Posts

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.
Rojalin Patri
RE: How to display account user's Prefix like(Mr,Ms,Dr,Mrs)
March 13, 2012 5:57 AM
Answer

Rojalin Patri

Rank: Expert

Posts: 287

Join Date: March 22, 2011

Recent Posts

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
RE: How to display account user's Prefix like(Mr,Ms,Dr,Mrs)
March 13, 2012 6:02 AM
Answer

Sarfarajali Kadiwala

Rank: New Member

Posts: 12

Join Date: September 17, 2010

Recent Posts

thanks bro. no problem.
Sarfarajali Kadiwala
RE: How to display account user's Prefix like(Mr,Ms,Dr,Mrs)
March 14, 2012 10:26 PM
Answer

Sarfarajali Kadiwala

Rank: New Member

Posts: 12

Join Date: September 17, 2010

Recent Posts

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.
Rojalin Patri
RE: How to display account user's Prefix like(Mr,Ms,Dr,Mrs)
March 14, 2012 10:57 PM
Answer

Rojalin Patri

Rank: Expert

Posts: 287

Join Date: March 22, 2011

Recent Posts

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
RE: How to display account user's Prefix like(Mr,Ms,Dr,Mrs)
March 16, 2012 11:56 PM
Answer

Sarfarajali Kadiwala

Rank: New Member

Posts: 12

Join Date: September 17, 2010

Recent Posts

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.