This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: Populating a ISComboBox with Country Names/Codes
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 07, 2007
02:19 PM
Populating a ISComboBox with Country Names/Codes
Hi,
I need to populate an IS combo box with different country names and associate each country with a code. So, for example, if the combobox is populated with countries like UNITED STATES(US), INDIA(IN), AUSTRALIA(AU), the combo box will display the country names to the user but will actually be storing the country codes (US,IN, AU etc.) in the background.
I intend to copy over the country code based on what country name the user selects to an output file.
How can I do this using InstallShield?.
Thanks very much!!
I need to populate an IS combo box with different country names and associate each country with a code. So, for example, if the combobox is populated with countries like UNITED STATES(US), INDIA(IN), AUSTRALIA(AU), the combo box will display the country names to the user but will actually be storing the country codes (US,IN, AU etc.) in the background.
I intend to copy over the country code based on what country name the user selects to an output file.
How can I do this using InstallShield?.
Thanks very much!!
(9) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 12, 2007
02:51 PM
Heres an example of code I am using to update some comboboxes....
[CODE] ISComboBox models = arg0.getISPanel().getComboBoxControl("jboss_cmb_deploy_servermodel");
ISComboBox existingServerNames = arg0.getISPanel().getComboBoxControl("jboss_cmb_deploy_servername");
String as_location = arg0.resolveString("$N($V(deploy_fb_appserver_location)/server)");
String servers[] = new File(as_location).list();
int count = 0;
Vector v = new Vector();
for ( int x = 0; x < servers.length ; x++)
{
File f = new File(as_location + "/" + servers);
if ( ( f.isDirectory() ) && ( f.canRead() ) )
{
//System.out.println(servers);
v.add(servers);
count++;
}
}
ISComboBoxDef defModels = (ISComboBoxDef)models.getControlDefinition();
ISComboBoxDef defExistingServerNames = (ISComboBoxDef)existingServerNames.getControlDefinition();
String list[] = new String[v.size()];
v.copyInto(list);
defModels.setValues(list);
defExistingServerNames.setValues(list);
models.refreshExtendedProperties();
existingServerNames.refreshExtendedProperties();[/CODE]
[CODE] ISComboBox models = arg0.getISPanel().getComboBoxControl("jboss_cmb_deploy_servermodel");
ISComboBox existingServerNames = arg0.getISPanel().getComboBoxControl("jboss_cmb_deploy_servername");
String as_location = arg0.resolveString("$N($V(deploy_fb_appserver_location)/server)");
String servers[] = new File(as_location).list();
int count = 0;
Vector v = new Vector();
for ( int x = 0; x < servers.length ; x++)
{
File f = new File(as_location + "/" + servers
if ( ( f.isDirectory() ) && ( f.canRead() ) )
{
//System.out.println(servers
v.add(servers
count++;
}
}
ISComboBoxDef defModels = (ISComboBoxDef)models.getControlDefinition();
ISComboBoxDef defExistingServerNames = (ISComboBoxDef)existingServerNames.getControlDefinition();
String list[] = new String[v.size()];
v.copyInto(list);
defModels.setValues(list);
defExistingServerNames.setValues(list);
models.refreshExtendedProperties();
existingServerNames.refreshExtendedProperties();[/CODE]
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 15, 2007
01:29 AM
Here is what I am doing. I have done it for US and INDIA for now, but plan to do the rest along the same lines. I am gonna have to hard code every country that's out there...is there a better way to do this?
Thanks
public void selectionChangedinsite2_country_list(com.installshield.event.ui.ISControlContext arg0)
{
try{
ISFrame frame = ((SwingPanel)arg0.getISContainer()).getISFrame();
ISComboBox cntryComboBox = (ISComboBox)arg0.getISControl();
String cntry = cntryComboBox.getSelectedValue();
if(cntry.equals("UNITED STATES")){
cntry = "US";
}
else if (cntry.equals("INDIA")){
cntry = "IN"
}
arg0.getServices().getISDatabase().setVariableValue("insite2_country",cntry);
} catch(Exception e){
arg0.getServices().logEvent(this, Log.ERROR, "Caught an exception........");
}
}
Thanks
public void selectionChangedinsite2_country_list(com.installshield.event.ui.ISControlContext arg0)
{
try{
ISFrame frame = ((SwingPanel)arg0.getISContainer()).getISFrame();
ISComboBox cntryComboBox = (ISComboBox)arg0.getISControl();
String cntry = cntryComboBox.getSelectedValue();
if(cntry.equals("UNITED STATES")){
cntry = "US";
}
else if (cntry.equals("INDIA")){
cntry = "IN"
}
arg0.getServices().getISDatabase().setVariableValue("insite2_country",cntry);
} catch(Exception e){
arg0.getServices().logEvent(this, Log.ERROR, "Caught an exception........");
}
}
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 15, 2007
08:56 AM
Well yes and no... There isnt a way to have the ISComboBox selected value represent another value... In other words there is no internal way to make a selection of 'United Stated' equal US. However, what i would do is this...
Create a string variable called countryCodes. Set the value to be something like
United States=US,INDIA=IN,etc....
Have your panel process this into a map or properties object. Then do something like....
Create a string variable called countryCodes. Set the value to be something like
United States=US,INDIA=IN,etc....
Have your panel process this into a map or properties object. Then do something like....
String selectedCountry= cntryComboBox.getSelectedValue();
String countryCode = countryCodesMap.getValue(selectedCountry);
selectedCountry=countryCode;
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 20, 2007
11:17 AM
There are like 200 countries..it would be hard for me to hard code all the countries..
I was looking at the following two options.
Option 1:
How about I embed a SQL statement in my InstallShield code and use a JDBC connection to retrieve the country code
String countryName = cntryComboBox.getSelectedValue();
String countryCodeQuery = "SELECT CODE
FROM COUNTRY_CODE WHERE COUNTRY_NAME = 'countryName' ;
//use JDBC to retrieve the country code.
executeQuery(countryCodeQuery);
Not sure how I can set up a JDBC/ODBC driver from within InstallShield though..I was also thinking of using an Excel spreadsheet( and not a db table) that will have all the countries/codes.
Is this a possible solution?
Option 2:
The other option I was considering was using a HashMap/HashTable with key/value pairs:
HashMap country = new HashMap()
country.put("US", "UNITED STATES");
country.put("IN","INDIA");
country.put("CA","CANADA");
....
............and so on
String countryName = countryComboBox.getSelectedValue();// Get the user selected country
String countryCode = country.get(countryName); // Get the country code
Option 2 is based on your solution. If 1 is not possible, I will go with 2.
Thanks
I was looking at the following two options.
Option 1:
How about I embed a SQL statement in my InstallShield code and use a JDBC connection to retrieve the country code
String countryName = cntryComboBox.getSelectedValue();
String countryCodeQuery = "SELECT CODE
FROM COUNTRY_CODE WHERE COUNTRY_NAME = 'countryName' ;
//use JDBC to retrieve the country code.
executeQuery(countryCodeQuery);
Not sure how I can set up a JDBC/ODBC driver from within InstallShield though..I was also thinking of using an Excel spreadsheet( and not a db table) that will have all the countries/codes.
Is this a possible solution?
Option 2:
The other option I was considering was using a HashMap/HashTable with key/value pairs:
HashMap country = new HashMap()
country.put("US", "UNITED STATES");
country.put("IN","INDIA");
country.put("CA","CANADA");
....
............and so on
String countryName = countryComboBox.getSelectedValue();// Get the user selected country
String countryCode = country.get(countryName); // Get the country code
Option 2 is based on your solution. If 1 is not possible, I will go with 2.
Thanks
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 20, 2007
11:37 AM
While certainly possible to use a database to access the values, I dont think its practical at all....
You would have to enter the country codes into the database to begin with, so why not just do it in code.
Heres a solution that may appeal. Just create a properties file that contains your codes:
United States=US
India=IN
etc...
After the user selects the country. Load the properties from the file and then get the associated code via the key.
I.E.,
There are like 200 countries..it would be hard for me to hard code all the countries..
You would have to enter the country codes into the database to begin with, so why not just do it in code.
Heres a solution that may appeal. Just create a properties file that contains your codes:
United States=US
India=IN
etc...
After the user selects the country. Load the properties from the file and then get the associated code via the key.
I.E.,
Properties p = new Properties();
p.loadProperties(InputSource is );
String countryCode = property.getProperty(userSelectedCountry);
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 20, 2007
01:02 PM
There are like 200 countries..it would be hard for me to hard code all the countries..
I was looking at the following two options.
Option 1:
How about I embed a SQL statement in my InstallShield code and use a JDBC connection to retrieve the country code
String countryName = cntryComboBox.getSelectedValue();
String countryCodeQuery = "SELECT CODE
FROM COUNTRY_CODE WHERE COUNTRY_NAME = 'countryName' ;
//use JDBC to retrieve the country code.
executeQuery(countryCodeQuery);
Not sure how I can set up a JDBC/ODBC driver from within InstallShield though..I was also thinking of using an Excel spreadsheet( and not a db table) that will have all the countries/codes.
Is this a possible solution?
Option 2:
The other option I was considering was using a HashMap/HashTable with key/value pairs:
HashMap country = new HashMap()
country.put("US", "UNITED STATES");
country.put("IN","INDIA");
country.put("CA","CANADA");
....
............and so on
String countryName = countryComboBox.getSelectedValue();// Get the user selected country
String countryCode = country.get(countryName); // Get the country code
Option 2 is based on your solution. If 1 is not possible, I will go with 2.
Thanks
I was looking at the following two options.
Option 1:
How about I embed a SQL statement in my InstallShield code and use a JDBC connection to retrieve the country code
String countryName = cntryComboBox.getSelectedValue();
String countryCodeQuery = "SELECT CODE
FROM COUNTRY_CODE WHERE COUNTRY_NAME = 'countryName' ;
//use JDBC to retrieve the country code.
executeQuery(countryCodeQuery);
Not sure how I can set up a JDBC/ODBC driver from within InstallShield though..I was also thinking of using an Excel spreadsheet( and not a db table) that will have all the countries/codes.
Is this a possible solution?
Option 2:
The other option I was considering was using a HashMap/HashTable with key/value pairs:
HashMap country = new HashMap()
country.put("US", "UNITED STATES");
country.put("IN","INDIA");
country.put("CA","CANADA");
....
............and so on
String countryName = countryComboBox.getSelectedValue();// Get the user selected country
String countryCode = country.get(countryName); // Get the country code
Option 2 is based on your solution. If 1 is not possible, I will go with 2.
Thanks
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 20, 2007
01:06 PM
I already have an Excel Spreadsheet that has all these countries/codes...was wondering if I could put it to use somehow..
Anyway, let me try your option out..important thing is that it should work.
Thanks
Anyway, let me try your option out..important thing is that it should work.
Thanks
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 20, 2007
01:16 PM
Personally, i wouldn't go that route, however if you really wanted to try, go for it... Checkout http://sourceforge.net/projects/xlsql. However, I think a properties file, or even a CSV file(which can be exported from excel) is more straight forward.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 23, 2007
03:42 PM
Okay..I used the HashMap and it's working now..
Thanks a lot for your help!
Thanks a lot for your help!
![](/skins/images/3B39CE851FDD5528C393F146EB70A2D0/responsive_peak/images/icon_anonymous_message.png)