Fórum
[Resolved] Getting a user phone number given its id
Bob Master Flash, modificado 17 Anos atrás.
[Resolved] Getting a user phone number given its id
New Member Postagens: 2 Data de Entrada: 13/03/07 Postagens Recentes
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, modificado 17 Anos atrás.
RE: Getting a user phone number given its id
New Member Postagens: 16 Data de Entrada: 19/10/06 Postagens Recentes
I'm having the exact same problem.
Any advice would be appreciated.
Any advice would be appreciated.
Nathan McMinn, modificado 17 Anos atrás.
RE: Getting a user phone number given its id
Junior Member Postagens: 61 Data de Entrada: 14/10/05 Postagens Recentes
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, modificado 17 Anos atrás.
RE: Getting a user phone number given its id
New Member Postagens: 2 Data de Entrada: 13/03/07 Postagens Recentes
Your solution is working fine.
Thanks a lot
Thanks a lot
delang j, modificado 15 Anos atrás.
RE: Getting a user phone number given its id
Expert Postagens: 252 Data de Entrada: 14/07/08 Postagens RecentesList 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, modificado 15 Anos atrás.
RE: Getting a user phone number given its id
Liferay Legend Postagens: 2047 Data de Entrada: 07/10/08 Postagens Recentes
I think it should be:
List<phone> phones = PhoneLocalServiceUtil.getPhones(companyId, className, classPK);</phone>
delang j, modificado 15 Anos atrás.
RE: Getting a user phone number given its id
Expert Postagens: 252 Data de Entrada: 14/07/08 Postagens Recentes
hi amos, what about the second line, is it correct?
please guide me
thanks
please guide me
thanks
Amos Fong, modificado 15 Anos atrás.
RE: Getting a user phone number given its id
Liferay Legend Postagens: 2047 Data de Entrada: 07/10/08 Postagens Recentes
If you look at say, pollsdisplay/view.jsp, you can iterate through the List like:
for (Phone phone : phones) {
phone.getNumber();
}
delang j, modificado 15 Anos atrás.
RE: Getting a user phone number given its id
Expert Postagens: 252 Data de Entrada: 14/07/08 Postagens Recentes
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, modificado 15 Anos atrás.
RE: Getting a user phone number given its id
Liferay Legend Postagens: 2047 Data de Entrada: 07/10/08 Postagens Recentes
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, modificado 15 Anos atrás.
RE: Getting a user phone number given its id
Expert Postagens: 252 Data de Entrada: 14/07/08 Postagens Recentes
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, modificado 15 Anos atrás.
RE: Getting a user phone number given its id
Liferay Legend Postagens: 2047 Data de Entrada: 07/10/08 Postagens Recentes
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, modificado 12 Anos atrás.
RE: Getting a user phone number given its id
Junior Member Postagens: 67 Data de Entrada: 07/09/11 Postagens Recentes
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