cancel
Showing results for 
Search instead for 
Did you mean: 

How to define onSelect action in code?

Former Member
0 Kudos

I created a dropdownbykey using dynamic way like below.

IWDDropDownByKey myDropDown = (IWDDropDownByKey) view.createElement(IWDDropDownByKey.class, "myDropDown ");

myContainer.addChild(myDropDown);

Now I want to add the code to set the onSelect action event for this drop down.

Does anyone knows and can give me this line of code?

Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Expert,

firstly you have to write code in WddoModify() method .

public void wdDoModify(IWDView view .................,boolean firstTime){

if(firstTime){

IWDDropDownByKey myDropDown = (IWDDropDownByKey) view.createElementIWDDropDownByKey.class, "myDropDown ");

//if attribute created to view context.

IWDAttributeinfo info=(IWDAttributeinfo)wdContext.getNodeInfo().getAttribute("attName");

myDropDown .bindAttribute(info);

ISimpleTypeModifiable ms=info.getModifiableSimpleType();

IModifiableSimpleValueset value=ms.getSVService().getModifiableSimpleValueSet();

value.put("1","sudhira");

value.put('2',"jati');

myDropDown .setOnSelect(wdThis.wdGetClickAction());

then...

you will cretae one action in view controler as Click.

open view--choose action tab in below-click on it--select on NeW button and create action name as Click

hope this will work

thanks

jati

myContainer.addChild(myDropDown);

}

}

Answers (4)

Answers (4)

Former Member
0 Kudos
gill367
Active Contributor
0 Kudos

Hi

do the following to create a dropdown by key in the view.

first write the following code in the wddomodifyview()

this will create a new dropdown ui element in the tray havin id "tray".

ddk_id is the id of the dropdown created

now bind its selected key property to the desired attribute

then you can set the onselect property to one of the actions created already in the view.

then write the code for what you want on selecting a particular key in the eventhandler of this action

as showm below:

write this code in wddomodifyview()

if(firstTime)
{

   IWDTray mytray = (IWDTray)view.getElement("Tray");
   IWDDropDownByKey ddk = (IWDDropDownByKey)view.createElement(IWDDropDownByKey.class,"ddk_id");
   IWDAttributeInfo attrinfo = wdContext.getNodeInfo().getAttribute("ddk");
   ddk.bindSelectedKey(attrinfo);
   *ddk.setOnSelect((IWDAction)view.getAction("SelectAction"));*   mytray.addChild(ddk);
}

Write the desired code for the action in the eventhandler as shown below

//@@begin javadoc:onActionSelect(ServerEvent)
  /** Declared validating event handler. */
  //@@end
  public void onActionSelect(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin onActionSelect(ServerEvent)
    //write the code here
    //@@end
  }

thanks hope it is clear

Sarbjeet Singh Gill

Former Member
0 Kudos

Hi,

Create a new action, say Actn_select

Now write the below code in wdDoModify.

IWDAction act = wdThis.wdGetActn_selectAction();
			myDropDown.setOnSelect(act);

Hope this helps..

Jithin

Edited by: jithin james on Apr 17, 2009 6:29 AM

Former Member
0 Kudos

If you have created an action "ItemSelected" at design-time, you can assign it using


myDropDown.setOnSelect( wdThis.wdGetItemSelectedAction() );

Armin