cancel
Showing results for 
Search instead for 
Did you mean: 

DropDownByIndex event

david_fryda2
Participant
0 Kudos

Hi everyone,

I have a little problem to capture what the user selected.

Here is the code.

public void wdDoInit()

{

//@@begin wdDoInit()

String[] letters = new String []{"A", "B", "C", "D"};

// Create context elements for the node "X"

List nodeElements = new ArrayList();

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

{

IPrivateTestComponentView.IXElement xElement = wdContext.createXElement();

xElement.setY(letters<i>);

nodeElements.add(xElement);

}

// Bind node element list to the node

wdContext.nodeX().bind(nodeElements);

// Set node’s lead selection which determines the selected item

wdContext.nodeX().setLeadSelection(0);

//@@end

}

1) What must I do to know what the user selected.

2) What is the difference with DropDownByKey ?

Thanks a lot for your precious help.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

1. You can the selected value by using

wdContext.currentXElement().getY().

2.

DropDown by Index

-


A DropDownByIndex UI element provides the user with a dropdown list box. You cannot select more than one entry from the selection list. The UI element consists of a text field, a button, and a selection list. An already selected list entry is displayed in the text field. When selecting the button, a list with all possible values is displayed

DropDown By Key

-


A DropDownByKey UI element provides the user with a selection list from which the user can select no more than one entry. The UI element consists of a text field, a button, and a selection list. An already selected list entry is displayed in the text field. When selecting the button, a list with all possible values is displayed.

The dropdown list box UI elements do not differ from each other when displayed on the screen.

Regards, Anilkumar

david_fryda2
Participant
0 Kudos

It works.

Thank you very much.

Maybe I can ask you a last question.

I am misunderstanding the diference between :

a) wdThis.wdGetContext().currentXElement().getY();

b) wdContext.currentXElement().getY();

Thank you a lot.

former_member182372
Active Contributor
0 Kudos

Hi David,

there is no difference. See constructor of your controller:

    this.wdThis = wdThis;
    this.wdContext = wdThis.wdGetContext();
    this.wdControllerAPI = wdThis.wdGetAPI();
    this.wdComponentAPI = wdThis.wdGetAPI().getComponent();

Regards, Maxim R.

david_fryda2
Participant
0 Kudos

Thanks friends!

I see it and it's the same.

In the action event, I get the selected item and all what it returns is the value...but where can I get the description ?

Thanks!

Message was edited by: David Fryda

Answers (2)

Answers (2)

Former Member
0 Kudos

Take a look on the forum this question has already been posted.

But I'm a kind person...

1/create a context attribute "text" as string, read-onlu true, calcutaled true.

2/ in <b>implementation</b>, search the function java.lang.String <b>getText</b>(IPrivateMain.IContextElement element). the name "getText" come from CalculateAttributeGetter

3/ add the following code

String attributeName = IPrivateMain.IContextElement.COLOR;

IWDAttributeInfo attributeInfo =

element.node().getNodeInfo().getAttribute(attributeName);

ISimpleType simpleType = attributeInfo.getSimpleType();

ISimpleValueSet valueset = simpleType.getSVServices().getValues();

Object key = element.getAttributeValue(attributeName);

try {

simpleType.checkValid(key);

return valueset.getText(key);

} catch (DdCheckException e) {

return "";

}

4/ create a new TextView and link it to the context "text".

5/ don't forget to define an action (name it select) and link this action to the UI dropDownByKey (Event OnSelect = select). leave the code of onActionSelect empty in the implementation.

6/ test it

7/ enjoy

david_fryda2
Participant
0 Kudos

Thank you a lot Mister Joseph Fryda...a know name...hum hum

Former Member
0 Kudos

HI,

wdThis Generated private interface of the view's controller provided by Web Dynpro

wdContext Generated interface of the view's context

More Info:-

For every Web Dynpro controller class different sets of interfaces are generated by the Web Dynpro

Generation Framework. Their names start with IPrivate, IPublic .

These interfaces specify the level of information/access a controller class exposes to another user.

The private access to the generated Web Dynpro Interface of type IPrivate for a controller class is

provided by the member varibale wdThis (it provides access to its own

Example: View Controller: MainView.java -->IPrivateMainView.java

Regards, Anilkumar