cancel
Showing results for 
Search instead for 
Did you mean: 

WebDynpro App Input Focus

former_member205400
Active Participant
0 Kudos

On my WebDynpro App i have an input field that I want to have focus when it is displayed.

On the Implementation section I have this init code

public StartView(IPrivateStartView wdThis)

{

this.wdThis = wdThis;

this.wdContext = wdThis.wdGetContext();

this.wdControllerAPI = wdThis.wdGetAPI();

this.wdComponentAPI = wdThis.wdGetAPI().getComponent();

}

I'm thinking I should add something like:

wdComponentAPI(name).getfocus();

Anyone get what I'm talking about?

Mike

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You can try it:

IWDInputField field=(IWDInputField)view.getElement("InputId");

field.requestFocus();

Put this code on wdDoModifyView of your View class. This method pass parameter firstTime, you can use its to set focus only at the first load.

Best regards

former_member205400
Active Participant
0 Kudos

Isaias,

I am getting "cannot be resolved or is not a type" on IWDInputField.

Mike

Former Member
0 Kudos

Hi,

Have you did import of IWDInputField?

See if have it on begin of file:

//@@begin imports

...

import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDInputField;

...

//@@end

Best regards

former_member205400
Active Participant
0 Kudos

Awesome .. it works .. only drawback is when I press the button on the screen after filling the input box is it stays in the field, i.e. as if it will never release focus.

Former Member
0 Kudos

Hi,

Are you using the firstTime parameter to execute this code only at first time?

public static void wdDoModifyView(IPrivate<view name> wdThis, Iprivate<view name>.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)

{

//@@begin wdDoModifyView

if (firstTime){

// Execute the code

}

//@@end

}

former_member205400
Active Participant
0 Kudos

I have this implememted, but when i push the button it takes me back still.

public static void wdDoModifyView(IPrivate<view name> wdThis, Iprivate<view name>.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)

{

//@@begin wdDoModifyView

if (firstTime){

// Execute the code

}

//@@end

}

Former Member
0 Kudos

Hi,

I think that the last focus will be maintained after click, you can do a workaround, on the action, you can set a property that indicate the modifyView do set the focus to button.

Best regards

Answers (0)