Skip to Content
avatar image
Former Member

Lost Cursor at RequestFocus

Hi all,

I have a problem with the cursor in Web Dynpro Java. When i set the focus in an InputField in a Table it works, but sometimes the cursor is not in this field. I use requestFocus.

I cant find any solution or cause for this problem.

Can someone help me here?

Thanks

Florian

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Jul 06, 2009 at 08:52 AM

    are you setting the request focus over the element each time an action happens? ...like clicking any button on the screen

    public void requestFocus(IWDNodeElement nodeElement,
                             IWDAttributeInfo attribute)

    Requests to change the keyboard input focus to the UI element whose primary use is to edit a property bound to the given attribute. If there is more than one such UI element, then it is undefined which UI element is chosen. It is also undefined which focus request wins if there are several ones. The request may silently fail, but is guaranteed not to throw an exception. UI elements that are read-only or disabled are not considered at all. To identify a given attribute uniquely at runtime, you must specify the node element to which that attribute belongs. This will e.g. identify a specific cell in a given table row. Example: If you have an input field whose "value" property is bound against the attribute abc of node XYZ of this view called MyView and no other UI element property is bound against XYZ.abc, then the following code will focus on that input field.

     IWDAttributeInfo attribute
       = wdContext.nodeXYZ().getNodeInfo().getAttribute(
           IPrivateMyView.IXYZElement.ABC);
     wdThis.wdGetAPI().requestFocus(wdContext.currentXYZElement(), attribute);

    Note how this allows to keep controller code independent of the UI, even of IDs used for UI elements. If the input field in the example above is later replaced by a DropDownByKey or some fancy new editor with "guess what I want" value help, the code to request focus remains unaffected.

    http://127.0.0.1:4947/help/topic/com.sap.tc.webdynpro.runtime.javadoc/com/sap/tc/webdynpro/progmodel/api/IWDViewController.html

    Edited by: Jean Carlo Abreu on Jul 6, 2009 11:15 AM

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 06, 2009 at 08:54 AM

    Hi,

    How are you setting the cursor focus in wdDoModifyView() method.

    You need to set as below.

    1. create one static global variable of type IWDView in the "begin others" as below.

    static com.sap.tc.webdynpro.progmodel.api.IWDView viewInst=null;

    2. in wdDoModifyView method:

    if(firstTime)
    {
    viewInst=view;
    }

    3. For example in some onAction you need to set the focus:

    onActionSelect()
    {
     IWDInputField inputElement = (IWDInputField)viewInst.getElement(focusRequest);
     inputElement.requestFocus();
    }

    Regards,

    Charan

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      I set the focus in the wdDoModifyView-method with the following code:

      	if (wdContext.currentContextElement().getNoteFieldChange()){
      		IWDAttributeInfo ai = wdContext.nodeProcessList().getNodeInfo().getAttribute("Note");
      		IProcessListElement lastLeadSelElem = (IProcessListElement)wdContext.currentProcessListElement();
      		wdThis.wdGetAPI().requestFocus(lastLeadSelElem, ai);
      
      		wdContext.currentContextElement().setNoteFieldChange(false);
      
      	}

      I set the boolean NoteFieldChange in an onAction-Method.

  • Jul 06, 2009 at 08:58 AM

    Hi,

    Try to use the following code....

    if(firstTime)

    {

    IWDInputField InputField = (IWDInputField) view.getElement("INPUT_1");

    InputField.requestFocus();

    }

    Regards,

    Lakshmi Prasad.

    Add comment
    10|10000 characters needed characters exceeded