Forums de discussion
[Resolved] Getting a user phone number given its id
Bob Master Flash, modifié il y a 17 années.
[Resolved] Getting a user phone number given its id
New Member Publications: 2 Date d'inscription: 13/03/07 Publications récentes
Hello
My question is simple : i would like to retrieve a user phone number list given the user id.
I can retrieve all user information (first name organization etc.) but for the phone numer list, there is no method...
I tried to retrieve it using PhoneUtil.findByUserId(userId) but i have no hibernate session...
I saw a addPhone method with a userId parameter, so i guess there is a way to have it using the api.
I cannot use the PortletRequest.USER_INFO because i want to display all portal users phone numbers.
Thanks a lot for your advice.
Me
My question is simple : i would like to retrieve a user phone number list given the user id.
I can retrieve all user information (first name organization etc.) but for the phone numer list, there is no method...
I tried to retrieve it using PhoneUtil.findByUserId(userId) but i have no hibernate session...
I saw a addPhone method with a userId parameter, so i guess there is a way to have it using the api.
I cannot use the PortletRequest.USER_INFO because i want to display all portal users phone numbers.
Thanks a lot for your advice.
Me
Shane W, modifié il y a 17 années.
RE: Getting a user phone number given its id
New Member Publications: 16 Date d'inscription: 19/10/06 Publications récentes
I'm having the exact same problem.
Any advice would be appreciated.
Any advice would be appreciated.
Nathan McMinn, modifié il y a 17 années.
RE: Getting a user phone number given its id
Junior Member Publications: 61 Date d'inscription: 14/10/05 Publications récentes
Check out PhoneLocalServiceUtil. You should be able to call:
Where companyId is the companyId you are using, classname is 'com.liferay.portal.model.Contact', and the classPk is the username you want.
This should return you a list of com.liferay.portal.model.Phone objects.
Let me know if it works
getPhones(String companyId, String className, String classPk)
Where companyId is the companyId you are using, classname is 'com.liferay.portal.model.Contact', and the classPk is the username you want.
This should return you a list of com.liferay.portal.model.Phone objects.
Let me know if it works
Bob Master Flash, modifié il y a 17 années.
RE: Getting a user phone number given its id
New Member Publications: 2 Date d'inscription: 13/03/07 Publications récentes
Your solution is working fine.
Thanks a lot
Thanks a lot
delang j, modifié il y a 15 années.
RE: Getting a user phone number given its id
Expert Publications: 252 Date d'inscription: 14/07/08 Publications récentesList phone = PhoneLocalServiceUtil.getPhones(companyId, className, classPK);
row.addText(ListUtil.toString(phone, "number", ", "), rowURL);
this is what i've done so far but without error and output. am i miss something. Please help me, i just want to display phone number on directory portlet.
thanks
Amos Fong, modifié il y a 15 années.
RE: Getting a user phone number given its id
Liferay Legend Publications: 2047 Date d'inscription: 07/10/08 Publications récentes
I think it should be:
List<phone> phones = PhoneLocalServiceUtil.getPhones(companyId, className, classPK);</phone>
delang j, modifié il y a 15 années.
RE: Getting a user phone number given its id
Expert Publications: 252 Date d'inscription: 14/07/08 Publications récentes
hi amos, what about the second line, is it correct?
please guide me
thanks
please guide me
thanks
Amos Fong, modifié il y a 15 années.
RE: Getting a user phone number given its id
Liferay Legend Publications: 2047 Date d'inscription: 07/10/08 Publications récentes
If you look at say, pollsdisplay/view.jsp, you can iterate through the List like:
for (Phone phone : phones) {
phone.getNumber();
}
delang j, modifié il y a 15 années.
RE: Getting a user phone number given its id
Expert Publications: 252 Date d'inscription: 14/07/08 Publications récentes
hi amos,
would you explain more details? newbie like me couldnt get it
thanks.
would you explain more details? newbie like me couldnt get it
thanks.
Amos Fong, modifié il y a 15 années.
RE: Getting a user phone number given its id
Liferay Legend Publications: 2047 Date d'inscription: 07/10/08 Publications récentes
The directory already shows phone numbers...if you look at phone_numbers.jsp:
if (classPK > 0) {
personalPhones = PhoneServiceUtil.getPhones(className, classPK);
}
........
<ul class="property-list">
<%
for (Phone phone: personalPhones) {
%>
<li class="<%= phone.isPrimary() ? " primary" : "" %>">
<%= PhoneNumberUtil.format(phone.getNumber()) %> <%= phone.getExtension() %> <%= LanguageUtil.get(pageContext, phone.getType().getName()) %>
</li>
<%
}
%>
</ul>
delang j, modifié il y a 15 années.
RE: Getting a user phone number given its id
Expert Publications: 252 Date d'inscription: 14/07/08 Publications récentes
thanks amos for the reply but i already done with different way. here the codes, somehow one of my friend give me help.
btw where is the phone_number.jsp file?
String phoneType = LanguageUtil.get(pageContext, "none");
String mobileNo = LanguageUtil.get(pageContext, "none");
String officeNo = LanguageUtil.get(pageContext, "none");
List resultsPhone = new ArrayList();
resultsPhone.addAll(PhoneLocalServiceUtil.getPhones(user2.getCompanyId(), Contact.class.getName(), contact2.getContactId()));
for (int p = 0; p < resultsPhone.size(); p++) {
Phone phone = (Phone)resultsPhone.get(p);
phoneType = phone.getType().getName();
if (phoneType.equals("Mobile")) mobileNo = phone.getNumber();
if (phoneType.equals("Business")) officeNo = phone.getNumber() + "<br>Ext: " + phone.getExtension();
}
btw where is the phone_number.jsp file?
Amos Fong, modifié il y a 15 années.
RE: Getting a user phone number given its id
Liferay Legend Publications: 2047 Date d'inscription: 07/10/08 Publications récentes
great!
phone_numbers.jsp is located in portal-web/docroot/html/portlet/directory/user
phone_numbers.jsp is located in portal-web/docroot/html/portlet/directory/user
Udaya Ramakrishnan, modifié il y a 12 années.
RE: Getting a user phone number given its id
Junior Member Publications: 67 Date d'inscription: 07/09/11 Publications récentes
hi
thank u so much for ur code.
let me post my code of what i did in directory portlet to have phone number..
In \html\portlet\directory\user\search_columns.jspf i included the following lines to have phone numbers into list:
This will include phone number into the list.
Attached the screen shots also
u can use the following link as reference: http://www.abcseo.com/tech/liferay/search-container
thank u so much for ur code.
let me post my code of what i did in directory portlet to have phone number..
In \html\portlet\directory\user\search_columns.jspf i included the following lines to have phone numbers into list:
[b]<%
ExpandoBridge eb = user.getExpandoBridge();
List<phone> phones = PhoneLocalServiceUtil.getPhones(user2.getCompanyId(), Contact.class.getName(), user2.getContactId());
String mobileNo = "";
String phoneNo = "";
for (Phone phone : phones) {
String phoneType = phone.getType().getName();
if ("Business".equals(phoneType)) {
phoneNo = phone.getNumber();
} else if ("Mobile".equals(phoneType)) {
mobileNo = phone.getNumber();
}
}
%>
<liferay-ui:search-container-column-text href="<%= rowURL %>" name="Phone" orderable="<%= true %>" value="<%= phoneNo %>" />
[/b]
</phone>
This will include phone number into the list.
Attached the screen shots also
u can use the following link as reference: http://www.abcseo.com/tech/liferay/search-container
Pièces jointes: