cancel
Showing results for 
Search instead for 
Did you mean: 

Populating dropdown box with countries

Former Member
0 Kudos

At the moment I am using DropDownByIndex.

IPrivateUserRegistrationView.ICountryElement ele;

for (int i = 0; i < countrynames.length; i++) {

ele = wdContext.nodeCountry().createCountryElement();

ele.setCountryname(countrynames<i>);

wdContext.nodeCountry().addElement(ele);

}

There is no problem with this.

However i would like to display value='England" and key = "EN"

that means when the user selects England, the backend server receive as "EN"

How can i achieve this?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

In CountryElement, create an additional String attribute for countrycode.

In your onSelectAction that is linked to your dropdownbyindex, you can get the user selected country code through:

wdContext.currentCountryElement().getCountryCode();

Good luck, Roelof

Former Member
0 Kudos

that was a useful answer.

appreciate that.

another question.

Do i put the piece of code in modifyView or init method?

Former Member
0 Kudos

Yes you can do it as per your requirement.If you want to display it as soon as the view is displayed you write the code in the init() method If you want to populate the dropdown after a event then write the code in your own action or domodify() method.

Former Member
0 Kudos

Hi,

In wdDoInit I would say.

You can also put it in wdModifyView, but then you must do it only once:

if (firsttime) {

fill context node here.

}

wdDoInit is preferred however.

Good luck, Roelof

PS Even better would be to do it in the wdDoInit method of the controller where do the backend call. You can map the context node to your view.

The advantage is that the selected country code is available in your controller, you don´t have to pass parameter variables from view to controller.

Edited by: R. Knibbe on Jan 25, 2008 3:44 PM

Answers (0)