cancel
Showing results for 
Search instead for 
Did you mean: 

Regarding the standard language,country,timezone dropdown list population.

Former Member
0 Kudos

Dear All,

I am currently trying to create portal user through webdynpro,in this regard i am replicating the standard user creation screen layout.In this i need to populate the Country ,Language and TimeZone drop downs with standard values .Request you to help me in guiding me how to populate these data and also let me know if there is any standard function to achieve the same.

Thanks and Regards,

Nishita Salver

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Dear Parvesh,

Good Morining.

Hey I am facing an error "Error is Type Mismatch cannot convert from Locale[] to Locale."

In the following location

Locale locale= Locale.getAvailableLocales();*//Error is Type Mismatch cannot convert from Locale[] to Locale.*
 
while( Locale.getAvailableLocales().length!=0)
{
 final String contry = locale.getDisplayCountry(); 
 if (contry.length() > 0) {
 wdComponentAPI.getMessageManager().reportSuccess("Country = " + contry + ". ISO code: " +  locale.getISO3Country());
 }
}
 
while(Locale.getAvailableLocales().length!=0)
{
 
final String language = locale.getLanguage();
 if (language.length() > 0) {
   wdComponentAPI.getMessageManager().reportSuccess("Language = " + language+ ". ISO code: " +   locale.getISO3Language());
  }
}

Request you to help me resolve this problem .

Thanks and Regards,

Nishita Salver

pravesh_verma
Active Contributor
0 Kudos

Hi Nishita,

Please remove the import statments which are related to the Local from your java class.. And then reimport the Local class. This will resolve you issue.

Please note that you have to include the util Local. Check after the reimport that you have following lines of code or not in your import statement.


import java.util.Locale;

Please revert back if you any issue! Always give the points to responses of your query!

Thanks and Regards,

Pravesh

Answers (7)

Answers (7)

Former Member
0 Kudos

Dear Parvesh,

The problem is solved.Thank you once again

Thanks and Regards,

Nishita Salver

Former Member
0 Kudos

Hi Pravesh,

The probelm is ":" is not supported in webdynpro that is why I had to change it to the ";" .Sorry to distrub you so much but I am still getting a error and this is one task because of which all my rest of the development is pending.Kindly request you to help is this regard.

Thanks in Advance.

Thanks and Regards,

Nishita Salver

pravesh_verma
Active Contributor
0 Kudos

Hi Nishita,

For of all no need to be sorry!! I can understand that you must be having some issues with the use of the syntax which I have sent. It may be possible that you are using JDK 1.4 however the syntax of the for loop which I have sent is from JAVA 5 version. Therefore it may be possible that you are getting the error.

Please note that as you said :

The probelm is ":" is not supported in webdynpro

is not a correct statement. It is not supported by your JDK verison i.e. your JAVA version. The compile time error is not coming becuase of WebDynpro or something else.

Anyways, you do one thing. Leave the confusion of for loop. Use the while loop as you were using earlier. Try and use this code:


Locale locale= Locale.getAvailableLocales();

while( Locale.getAvailableLocales().length!=0)
{
 final String contry = locale.getDisplayCountry(); 
 if (contry.length() > 0) {
 wdComponentAPI.getMessageManager().reportSuccess("Country = " + contry + ". ISO code: " +  locale.getISO3Country());
 }
}

while(Locale.getAvailableLocales().length!=0)
{
 
final String language = locale.getLanguage();
 if (language.length() > 0) {
   wdComponentAPI.getMessageManager().reportSuccess("Language = " + language+ ". ISO code: " +   locale.getISO3Language());
  }
}

I am sure this will solve you issue. Please close the thread if your issue is resolved. In case you have any issue, please do not hesitate and revert back!

Thanks and Regards,

Pravesh

Former Member
0 Kudos

Dear Pravesh,

As suggested by you I am using the for loop

CODE:

for (Locale locale ; Locale.getAvailableLocales().length!=0;) //I am getting an error locale not initialized and i cant use a colon as you used as webdynpro doesnt support

{

final String contry = locale.getDisplayCountry();

if (contry.length() > 0) {

wdComponentAPI.getMessageManager().reportSuccess("Country = " + contry + ". ISO code: " + locale.getISO3Country());

}

}

for (Locale locale ; Locale.getAvailableLocales().length!=0;)

{

final String language = locale.getLanguage();

if (language.length() > 0) { wdComponentAPI.getMessageManager().reportSuccess("Language = " + language+ ". ISO code: " + locale.getISO3Language());

}

and if i give it like Locale locale=null I am getting Null pointer exception.

Please guide me through to rectify the error.It would be of great help to me.

Thanks in Advance

Thanks and Regards,

Nishita Salver

pravesh_verma
Active Contributor
0 Kudos

Hi Nishita,

Please note that I have not used semicolon its just a colon. If you dont know how to use the JAVA 5 formats, then you can use the old way of using this. By the way I have already answered the question my reply above.

Please see the loop again:


for (Locale locale : Locale.getAvailableLocales()) {
          final String contry = locale.getDisplayCountry();
          if (contry.length() > 0) {
              System.out.println("Country = " + contry + ". ISO code: " + locale.getISO3Country());
          }
      }

And notice the diffrence between ";" and ":". I hope this solves the issue.

Please close the thread if problem is solved.

Thanks and Regards,

Pravesh

Former Member
0 Kudos

Dear Pravesh,

Thank you for your valuable reply. I have made used of your code and I am able to fetch the timezone but when i am trying fetch the country and the language list i am getting the Null Pointer Exception .

I have modified your code as i am making use of it in Webdynpro the code i am using is :

Locale locale=null;

while( Locale.getAvailableLocales().length!=0)

{

final String contry = locale.getDisplayCountry(); //I am getting the exception in this Line

if (contry.length() > 0) {

wdComponentAPI.getMessageManager().reportSuccess("Country = " + contry + ". ISO code: " + locale.getISO3Country());

}

}

while(Locale.getAvailableLocales().length!=0)

{

final String language = locale.getLanguage();

if (language.length() > 0) {

wdComponentAPI.getMessageManager().reportSuccess("Language = " + language+ ". ISO code: " + locale.getISO3Language());

}

}

Please can you guide me in how to rectify this error because of this issue I am held up with the rest of other developments.

Thanks and Regards,

Nishita Salver

pravesh_verma
Active Contributor
0 Kudos

Hi Nishita,

Obviously you will get the null pointer exception.. Please note that the code sent by me is taking the value of the locale initialized in the for loop itself.

Whereas you have initialized the local with null before the while loop and then trying to access it. Therefore it is giving a nullpointer exception in the line you have mentioned. The null pointer always comes when you try to access some object which is not available.

Please use the for loop directly OR if you want to use the while loop then initialize the local as:


Locale locale= Locale.getAvailableLocales();

I hope this will your issue. If the solution are helpful always consider giving points to them!

If you face any other problem please let me know.

Thanks and Regards

Pravesh

pravesh_verma
Active Contributor
0 Kudos

Hi Nishita,

You can use following code for getting all the details:

For all time zones.


Date today = new Date();
    
    // Get all time zone ids
    String[] zoneIds = TimeZone.getAvailableIDs();
    
    // View every time zone
    for (int i=0; i<zoneIds.length; i++) {
        // Get time zone by time zone id
        TimeZone tz = TimeZone.getTimeZone(zoneIds<i>);
    
        // Get the display name
        String shortName = tz.getDisplayName(tz.inDaylightTime(today), TimeZone.SHORT);
        String longName = tz.getDisplayName(tz.inDaylightTime(today), TimeZone.LONG);
    
        // Get the number of hours from GMT
        int rawOffset = tz.getRawOffset();
        int hour = rawOffset / (60*60*1000);
        int min = Math.abs(rawOffset / (60*1000)) % 60;
    
        // Does the time zone have a daylight savings time period?
        boolean hasDST = tz.useDaylightTime();
    
        // Is the time zone currently in a daylight savings time?
        boolean inDST = tz.inDaylightTime(today);
    }

For all Languages and Countries


for (Locale locale : Locale.getAvailableLocales()) {
          final String contry = locale.getDisplayCountry();
          if (contry.length() > 0) {
              System.out.println("Country = " + contry + ". ISO code: " + locale.getISO3Country());
          }
      }

for (Locale locale : Locale.getAvailableLocales()) {
          final String language = locale.getLanguage();
          if (language.length() > 0) {
              System.out.println("Language = " + language+ ". ISO code: " + locale.getISO3Language());
          }
    }

I hope this helps you!! Please revert backin case you have any issues.

Thanks and Regards

Pravesh

chander_kararia4
Contributor
0 Kudos

Hi Nishita,

Are you planning to get the details everytime from backend or trying to hardcode them in the dropdowns?

If so the case, application will be very bulky & will take much time to load everytime started.

I suggest, go with the webservices. Above method will be troublesome.

Regards

Chander Kararia

former_member185086
Active Contributor
0 Kudos

Hi Nishita

It a bit lengthy to explain but I try

1. For standard function you have to search It might you get some free web service URL which u can use in your webdynpro application.I am bit sure something for this kind of services is there because its very common

2.In J2EE user creation they use Language(around 130) ,cover all the Country and timezone(around 600) .so its not feasible to define this much of data in Dropdown enamoration.

3. To make it short what you can do is make a country List and put dependency of timezone and language on it means ones the country is selected default language and timezone get populated.consult it with your database guy.

Best Regards

Satish Kumar