cancel
Showing results for 
Search instead for 
Did you mean: 

Request Focus for Dropdown UI Element

Former Member
0 Kudos

Hi

Before submitting form we are doing some validation whether all mandatory fields are entered by end user.During that process if the user didnt enter mandatory fields values we are showing message to user and set focus to that particular UI element

I'm trying to set focus to my Dropdown(Dropdown by index) UI element using the wdControllerAPI .requestFocus(IWDNodeElement arg0,IWDAttributeInfo arg1).It is NOT working

The same works fine for InputField UI element

Is there any way to set focus to Dropdown UI element

Regards

Noel

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Have you tried using the ReportContextAttributeMessage method? The UI element automatically receives the focus.

Former Member
0 Kudos

Hi Noel,

I just check the code above suggested for request focus of DropDownByIndex. It just doesn't work as the conventional means to request focus for Input Field or DropDownByKey. I believe this is a bug in the current NWDS version.

I would suggest you to use DropDownByIndex to DropDownByKey if possible to get the required functionality.

Otherwise, I would suggest you to have input fields in each of the section of the screen where you need to request for focus with a width of zero and bound to context attribute of type string. This way, your Input Field would not be visible and moreover RequestFocus() method would return the focus of the screen to desirable section.

Having one inputfield against each DropDownByIndex (Next to It) would not be recommended as it would be tidicious and moreover would hit the performance because of unnecessary UI elements on screen.

Regards,

Tushar Sinha

Former Member
0 Kudos

Please, DO NOT store your View elements in the Context. There's really no need to do that.

What I have here is a Context Attribute, type String which I assign what element should use the "requestFocus()" method. In wdDoModify you can check whether this value is not null, so you can do view.getElement(value) and use the requestFocus. After that, set back to null.

In your validation method, you set this value to whatever you want.

Regards.

Daniel

Former Member
0 Kudos

Hi,

create a context attribute (name:Dropd) of type:com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDDropDownByIndex

and in wdDOModifyView() method write the code to get the intance of dropdown


  public static void wdDoModifyView(IPrivateXXXView wdThis, IPrivateXXXView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
  {
    //@@begin wdDoModifyView
    if(firstTime){
    
    IWDDropDownByIndex dopIndex=(IWDDropDownByIndex)view.getElement("dopdownID");
    wdContext.currentContextElement().setDropd(dopIndex);
    }
    //@@end
  }

In your validation method : get the attribute and call the requestFocus() method.


wdContext.currentContextElement().getDropd().requestFocus();

Regards,

Naga