cancel
Showing results for 
Search instead for 
Did you mean: 

Difference bet DropdownbyIndex and byKey....??

Former Member
0 Kudos

Dear Experts,

My task is to have two dropdowns

say for example...

  • In the first dropdown i need to have 5 Countries where i should select one of the choices

*Corresponding to the country selected, it should give 5 cities where in here no selection should be done.just displaying in this dropdown.

Please suggest me the dropdown i should use here... and also the steps,properties and the mapping for this task...

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Vinod,

The best solution here is:

1. One 0..n context node, selection 0..1 singleton=true -- Countries

2. Second node is child of Countries -- Cities, 0..n, selection 0..1 singleton=flase (or singleton=true + supplyFunction)

3. Bind property texts of first DropDownByIndex to attribute in Countries node, bind property texts of second DropDownByIndex to attribute in Cities node.

4. Populate both Countries/Cities nodes in wdDoInit or create supply functions for both or populate Countries in wdDoInit and define supplyFunction for Cities

All the rest will be handled automatically by WD.

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

Former Member
0 Kudos

Thanx Valery Silaev,

Can u give me the diff bet ByIndex and ByKey... and which one to be use here...???

Plz do give me the logic and the code for the Supply Functions.....

Former Member
0 Kudos

Hi Vinod,

As suggested by Valery, in the Supply Function get the Country and populate the States node with corresponding values.

Difference between DropdownbyIndex and byKey is:

DropDownByKey provides static data in DropDown and DropDownByIndex makes it dynamic.

DropDownByKey: Is used when u want to use data dictionary type.For this create a dictionary of simple type in the dictionary.

Creating the Simple Type:

Ur project>dictionaries>Data Types-->Simple Types right click and select Create Simple Type.

After entering the name and package, open that and click on "enumeration" tab at the bottom of the same. Now add the Value and Description to be displayed.The created simple type can be used for DropDownByKey.

Binding it to the UI element:

Now create a valueattribute and change the type to the dictionary type(created simple type). Finally bind the DropDownByKey UI element to the value attribute.

DropDownByIndex: Is used while we have to get the data from the database. Here we directly bind the DropDownByIndex UI element to the context node(attribute).

Regards,

Jhansi

Former Member
0 Kudos

Hai Vinod

wdDoinit(){

String countries[]={"India","USA","Germany"};

String india[]={"Delehi","Bangalore","Hyderabad"};

String USA[]={"Chicago","Washington"};

String GER[]={"Frankfort"};

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

Iprivate(xx)View.ICountryElement country=wdContext.createCountryElement();

country.setName(countries<i>);

wdContext.nodeCountryElement().addElement(country);

}

}

//create a action for country Dropdown

actionOfCountrySelect{

String selectedCountry=wdContext.currentCountryElement().getName();

ArrayList al=new ArrayList();

if(selectedCountry.equals("India")){

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

Iprivate(xx)View.IStateElement state=wdContext.createStateElement();

state.setName(india<i>);

al.add(state);

}

wdContext.nodeStateElement().bind(al);

}

}

Regards,

Former Member
0 Kudos

Vinod,

DropDownByIndex uses node elements as source of texts. The currently selected element corresponds to lead selection in node. When user change selection in drop down, the lead selected element in node changes as well.

DropDownByKey uses enumeration defined for DDIC type. This enumeration actually a map from key to descriptive text. So drop down shows descriptive texts to user but uses keys when altering corresponding context attribute (to which DropDownByKey.selectedKey is bound).

Supply functions is one of mechanisms to populate content of node. You may create all elements in advance in wdDoInit of controller or some action handler ("eager loading"). Or you may define supply function and it will be invoked when it's necessary to populate node -- typically the first code that causes loading is rendering code ("laizy loading").

I strongly recommend you to (re-) read corresponding tutorials on Web Dynpro area of SDN for better understanding.

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

Former Member
0 Kudos

U r amazing...!!!

A Bunch of Thanx for u Valery...!!

Answers (0)