cancel
Showing results for 
Search instead for 
Did you mean: 

request focus for message area

0 Kudos

Dear All,

As my screen is long hence if an error comes we will require to scroll down so I have added a message area UI element and in do modify method of the view i have request focus to my message area but it is not working. Below is the code which I have written:

try{

IWDMessageArea msgarea=(MessageArea)view.getElement("MessageArea");

msgarea.requestFocus();

}

catch(Exception e)

{

}

Is there any other property or changes need to be made.

Thankyou.

Regards,

Santosh

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi All,

I found this thread looking for the solution to the same topic and it helped a lot so I like to share an alternative solution:

public void wdDoModifyView(com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)

{

//@@begin wdDoModifyView

if(!wdComponentAPI.getMessageManager().isEmpty()){

view.getElement("MainMessageArea").requestFocus();

}

//@@end

}

Regards,

Andrés Acero

Former Member
0 Kudos

Hi,

In would say, create an input field at the top left corner of the screen. Set its width to zero and bind it to a context attribute say Va_ShowMesg of type string. Now insert a MessageArea UI element just below the inputfield to display all the erro message at the top left.

Now if you request focus for the input field using the following code, the focus will automatically come to the Message Area as well.

wdThis.wdGetAPI().requestFocus(wdContext.currentContextElement(),wdContext.getNodeInfo().getAttribute(

wdContext.currentContextElement().VA__SHOW_MESG));

You can call this code whenever you need to display message to user in the message area and shift focus of the screen to the message displayed.

Regards,

Tushar Sinha

Former Member
0 Kudos

Hi,

Check the below Forum thread, it actually worked.

Regards,

Smita

Former Member
0 Kudos

Hi Friend,

The Very First thing is that you should not use the modify view hook method without condition according to the best practices. you can shift this code to the on change of the UI element from which you are getting that Exception.

2nd you can put the message area on the top of the view.

Regards

Jeetendra.

Former Member
0 Kudos

Hi,

I guess the best solution as said before is declaring a Message Area UI element in the top.

Regards,

Daniel

Former Member
0 Kudos

Yes, that is the best solution.

Armin

0 Kudos

Dear all,

The problem was because we have been using several DCs with same UI Id for Message area and the same code.Now we implemented the Message area in a central DC which calls all the other DCs and this worked

Thanks a lot for all your suggestions

Santosh