Grails Cookbook - A collection of tutorials and examples

Grails country Tag Example

The Grails country tag (<g:country>) can be used to render the default English name of a country given the ISO3166_3 3-letter code. This will show a simple example on how to use this.

Example

This code using the country tag:

<g:country code="ita"/>

Will simple render this:

Italy

In practice, this tag is used to render the country name saved from countrySelect tag. For example, the value saved from this code:

<g:countrySelect name="countryCode" 
    value="${shopInstance?.countryCode}"
    noSelection="['':'-Choose your country-']"/>

Can be displayed on another page using this:

<g:country code="${shopInstance?.countryCode}"/>

Reference


For convenience, here is the list of country codes and their corresponding name that is rendered by country tag.

ISO3166_3 CodeRendered Text
afgAfghanistan
albAlbania
dzaAlgeria
asmAmerican Samoa
andAndorra
agoAngola
aiaAnguilla
ataAntarctica
atgAntigua and Barbuda
argArgentina
armArmenia
abwAruba
ausAustralia
autAustria
azeAzerbaijan
bhsBahamas
bhrBahrain
bgdBangladesh
brbBarbados
blrBelarus
belBelgium
blzBelize
benBenin
bmuBermuda
btnBhutan
bolBolivia
bihBosnia and Herzegovina
bwaBotswana
bvtBouvet Island
braBrazil
iotBritish Indian Ocean Territory
vgbBritish Virgin Islands
brnBrunei Darussalam
bgrBulgaria
bfaBurkina Faso
bdiBurundi
khmCambodia
cmrCameroon
canCanada
cpvCape Verde
cymCayman Islands
cafCentral African
tcdChad
chlChile
chnChina
cxrChristmas Island
cckCocos (Keeling) Islands
colColombia
comComoros
cokCook Islands
criCosta Rica
hrvCroatia
cubCuba
cypCyprus
czeCzech Republic
civCôte d'Ivoire
prkDemocratic People's Republic of Korea
dnkDenmark
djiDjibouti
dmaDominica
domDominican Republic
ecuEcuador
egyEgypt
slvEl Salvador
gnqEquatorial Guinea
eriEritrea
estEstonia
ethEthiopia
flkFalkland Islands
froFaroe Islands
fsmFederated States of Micronesia
fjiFiji
finFinland
fraFrance
gufFrench Guiana
pyfFrench Polynesia
atfFrench Southern Territories
gabGabon
gmbGambia
geoGeorgia
deuGermany
ghaGhana
gibGibraltar
grcGreece
grlGreenland
grdGrenada
glpGuadeloupe
gumGuam
gtmGuatemala
ginGuinea
gnbGuinea-Bissau
guyGuyana
htiHaiti
hmdHeard Island and McDonald Islands
hndHonduras
hkgHong Kong
hunHungary
islIceland
indIndia
idnIndonesia
irqIraq
irlIreland
irnIslamic Republic of Iran
imnIsle of Man
isrIsrael
itaItaly
jamJamaica
jpnJapan
jorJordan
kazKazakhstan
kenKenya
kirKiribati
kwtKuwait
kgzKyrgyzstan
laoLao People's Democratic Republic
lvaLatvia
lbnLebanon
lsoLesotho
lbrLiberia
lbyLibyan Arab Jamahiriya
lieLiechtenstein
ltuLithuania
luxLuxembourg
macMacao
mdgMadagascar
mwiMalawi
mysMalaysia
mdvMaldives
mliMali
mltMalta
mhlMarshall Islands
mtqMartinique
mrtMauritania
musMauritius
mytMayotte
mexMexico
mcoMonaco
mngMongolia
msrMontserrat
marMorocco
mozMozambique
mmrMyanmar
namNamibia
nruNauru
nplNepal
nldNetherlands
antNetherlands Antilles
nclNew Caledonia
nzlNew Zealand
nicNicaragua
nerNiger
ngaNigeria
niuNiue
nfkNorfolk Island
mnpNorthern Mariana Islands
norNorway
pseOccupied Palestinian Territory
omnOman
pakPakistan
plwPalau
panPanama
pngPapua New Guinea
pryParaguay
perPeru
phlPhilippines
pcnPitcairn
polPoland
prtPortugal
priPuerto Rico
qatQatar
korRepublic of Korea
mdaRepublic of Moldova
cogRepublic of the Congo
rouRomania
rusRussian Federation
rwaRwanda
reuRéunion
shnSaint Helena
knaSaint Kitts and Nevis
lcaSaint Lucia
vctSaint Vincent and the Grenadines
spmSaint-Pierre and Miquelon
wsmSamoa
smrSan Marino
stpSao Tome and Principe
sauSaudi Arabia
senSenegal
scgSerbia and Montenegro
sycSeychelles
sleSierra Leone
sgpSingapore
svkSlovakia
svnSlovenia
slbSolomon Islands
somSomalia
zafSouth Africa
sgsSouth Georgia and the South Sandwich Islands
espSpain
lkaSri Lanka
sdnSudan
surSuriname
sjmSvalbard and Jan Mayen
swzSwaziland
sweSweden
cheSwitzerland
syrSyrian Arab Republic
twnTaiwan
tjkTajikistan
thaThailand
codThe Democratic Republic Of The Congo
mkdThe Former Yugoslav Republic of Macedonia
tlsTimor-Leste
tgoTogo
tklTokelau
tonTonga
ttoTrinidad and Tobago
tunTunisia
turTurkey
tkmTurkmenistan
tcaTurks and Caicos Islands
tuvTuvalu
virU.S. Virgin Islands
ugaUganda
ukrUkraine
areUnited Arab Emirates
gbrUnited Kingdom
tzaUnited Republic Of Tanzania
usaUnited States
umiUnited States Minor Outlying Islands
uryUruguay
uzbUzbekistan
vutVanuatu
vatVatican City State
venVenezuela
vnmVietnam
wlfWallis and Futuna
eshWestern Sahara
yemYemen
zmbZambia
zweZimbabwe
alaÅland Islands


Other Grails Tag Examples


Tags: country, Grails Tag