掲示板

How to format phone number?

thumbnail
13年前 に Andrej Litowka によって更新されました。

How to format phone number?

Junior Member 投稿: 79 参加年月日: 10/06/30 最新の投稿
Hello all,

I'm using liferay 6.0.2 and adding phone numbers in a portlet with PhoneServiceUtil.updatePhone or PhoneServiceUtil.addPhone. Even if I enter the phone number as e.g. +49 (0) 111 222 333 it will be saved in the table Phone as 49111222333 and also shown on the page like this. I would save the phone number in the same format as I entered it in the form. The field Phone.number_ is a VARCHAR, so it should be possible. Is there any liferay build-in functionality to save the numbers in my own format? How I can configure this? If not, is the only possibility to format phone numbers to implement own PhoneNumberFormat? Currently only USAPhoneNumberFormat is available. There is no formater for Europe.

Thanks and regards,
Andrej
12年前 に A. Morgenröter によって更新されました。

RE: How to format phone number? (回答)

New Member 投稿: 10 参加年月日: 10/02/03 最新の投稿
Hello Andrej,

just set
##
## Format
##

#
# Set the location of the class that implements
# com.liferay.format.PhoneNumberFormat. This class will format phone
# numbers.
#
#com.liferay.util.format.PhoneNumberFormat=com.liferay.util.format.USAPhoneNumberFormat
com.liferay.util.format.PhoneNumberFormat=com.liferay.util.format.IdenticalPhoneNumberFormat


in your system-ext.properties and restart Liferay. Works fine using LP6 GA4.

Best Regards.
thumbnail
11年前 に Jack Bakker によって更新されました。

RE: How to format phone number?

Liferay Master 投稿: 978 参加年月日: 10/01/03 最新の投稿
com.liferay.util.format options are not comprehensive, of course neither are my phoneformat utils that I've been putting in a seperate *clientname*-utils that I export as jar to global classpath

there is a google libphonenumber (http://code.google.com/p/libphonenumber/) I am currently reviewing

are u experienced ? if so pls share... thx
thumbnail
11年前 に Hitoshi Ozawa によって更新されました。

RE: How to format phone number?

Liferay Legend 投稿: 7942 参加年月日: 10/03/24 最新の投稿
The major problem with the current com.liferay.util.format is that I'm not able to specify different format for different locale. That is, if I have it in US format, I can't have Japanese format as well.
thumbnail
11年前 に Jack Bakker によって更新されました。

RE: How to format phone number?

Liferay Master 投稿: 978 参加年月日: 10/01/03 最新の投稿
yes Hitoshi, u have restated my wondering need

the chosen Borg takes time to assimilate
thumbnail
11年前 に Hitoshi Ozawa によって更新されました。

RE: How to format phone number?

Liferay Legend 投稿: 7942 参加年月日: 10/03/24 最新の投稿
I've been adding country/lang attributes to jsp selections but I don't think I can do the same with phone number because a Japanese user may want to enter US phone number. I think I'll add a countryId parameter to a method to verify phone number. I'll put this in my backlog because I don't need it in a hurry.

Fall is the event time in Japan to get users to budget for next financial year. Kind of busy on this front lately.
11年前 に Xav NYC によって更新されました。

RE: How to format phone number?

New Member 投稿: 23 参加年月日: 12/09/27 最新の投稿
Hi the google phone number library does just that. https://code.google.com/p/libphonenumber/
It's a matter of integrating it to Liferay.
thumbnail
11年前 に Hitoshi Ozawa によって更新されました。

RE: How to format phone number?

Liferay Legend 投稿: 7942 参加年月日: 10/03/24 最新の投稿
Thanks for the information. I think I'll be able to use that in my Japanese edition of liferay.
5年前 に Καλλια Γαλιωτου によって更新されました。

RE: How to format phone number?

New Member 投稿: 3 参加年月日: 18/11/15 最新の投稿

Hello,

 

i have similar problem using Liferay 7.0. And I cant find system-ext.properties file, in order to add 

com.liferay.util.format.PhoneNumberFormat=com.liferay.util.format.IdenticalPhoneNumberFormat

 

I am using Number in my form and the user can insert only 9 digits.

 

Any help?

 

Thanks.

thumbnail
5年前 に Sandeep Nair によって更新されました。

RE: How to format phone number?

Liferay Legend 投稿: 1744 参加年月日: 08/11/06 最新の投稿

You have to create a property hook module specified here and then add the following property

phone.number.format.impl=com.liferay.portal.format.IdenticalPhoneNumberFormatImpl