cancel
Showing results for 
Search instead for 
Did you mean: 

Cursor Focus

Former Member
0 Kudos

Hi,

I have a testedit UI field in my view with data and edit button also there down of the textedit.now when i clicked edit button the cursor should be displayed in the textedit filed.Can anybody give me idea regarding this.

With Regards,

Prasad

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

The solution by Pravesh Verma should work fine.

Check the parameters(id of text edit, etc..) that you have mentioned are proper and correct.

AM

Answers (11)

Answers (11)

Former Member
0 Kudos

Hi Sarbjet,

I had tryed your code but still it not showing the focus.Any thing else i need to do ..

Thanks,

Prasad

Former Member
0 Kudos

Hi,

If possible pls post the code you wrote.

in the wdDoModifyView and aswell as in the button action also.

Regarding the approach suggested by Pravesh.

Regards,

Charan

Former Member
0 Kudos

HI Srinavas,

I assigend value attribute which is realted to model attribute to UI element.I am enter text at runtime also and i created VIEW of type IWDVIEW.I dontknow where the problem occuring.

With Regards,

Prasad

Former Member
0 Kudos

Hi,

Can you just try binding an value attribute instead of model attribute to "Value" property of that UI element?

Regards,

Charan

gill367
Active Contributor
0 Kudos

Hi Prasad,

Even if you are binding the TEXT EDIT ui element to a model attribute coming from the backend

Still you can use the method suggested by me to get the focus

You just need to get the attrinute info that particular attrinute

and in the eventhandler write the followin code

public void onActionEDIT(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin onActionEDIT(ServerEvent)
	IWDAttributeInfo attrinfo = wdContext.nodeReturn().getNodeInfo().getAttribute(IPrivateTESTView.IReturnElement.MESSAGE);
		wdThis.wdGetAPI().requestFocus(wdContext.currentReturnElement(),attrinfo);

    
    //@@end
  }

here i am attribute message from the return node which is a model attribute and i am getting it fromthe backend

and its working fine for me

thanks

Sarb

Former Member
0 Kudos

HI krishna,

Actually in that textedit UI element i am displaying data which is coming from backend.So i assigned model attribute to that TextEdit element.The value attribute VIEW of type IWDVIEW is not assiged to that TextEdit field.May be this is the problem i think.Can you tell me alternate solution

Thanks,

Prasad

Former Member
0 Kudos

Hi,

You need not to bind the Context attribute "View" of type "IWDVeiw" to the UI element. This context attribute is to store the static view instance.

I dont think the model attribute is a problem.

Just confirm me. Is it displaying in editable mode. I mean can you enter some data at runtime into that UI element?

Can you just try binding an value attribute instead of model attribute to "Value" property of that UI element?

Regards,

Charan

Former Member
0 Kudos

Hi,

Pls try as Parvesh said. 100% It works.

-->Before this check that you binded the String type context attribute to value property of TextEdit UI element.

--> ReadOnly should be false.

public static void wdDoModifyView(IPrivateTestView wdThis, IPrivateExportToExcelView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
  {
    //@@begin wdDoModifyView
    
	if(firstTime)
	{
		wdContext.currentContextElement().setView(view);
	}

}

In the edit button action:


IWDView view = wdContext.currentContextElement().getView();
IWDTextEdit textEdit = (IWDTextEdit)view.getElement("TextEdit1");
textEdit.requestFocus();

How to get the Id of the TextEdit UI element.

Go to the properties of the UI element --> Get from Id property.

Regards,

Charan

Former Member
0 Kudos

Hi,

In the DoModifyView Give the below code and try if the curser is coming to the textedit, by default

textEdit.requestFocus();IWDTextEdit textEdit = (IWDTextEdit)view.getElement("TextEdit");

textEdit.requestFocus();

if not, click on the TextEdit and confirm the curser is coming,

Let me know the results then.

AM

Former Member
0 Kudos

Hi Anoop,

I hae mentioned the correct textedit UIelement ID.But its not working.

my id name is TextEdit and i mentioned the same but noresult.

Can yu please give me idea reagarding this.

With Regards,

Prasad

Former Member
0 Kudos

Hi Praveen,

i have used your code in my application but its not working.Cursor not showing in testdit filed

With Regards,

Prasad Kamina

gill367
Active Contributor
0 Kudos

hello prasad,

To set the cursor focus on the text edit on click of the button edit, do the following

1. bind the UI element Text Edit to one context attribute (suppose it is a value attribute bound

directly to context root node named

source )

2. create an action for the click event of the Button EDIT (suppose its name is EDIT)

This will create an eventhandler OnActionEdit() in the implementation.

3. Now write the code in the event handler as shown below

    //@@begin javadoc:onActionEDIT(ServerEvent)
  /** Declared validating event handler. */
  //@@end
  public void onActionEDIT(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin onActionEDIT(ServerEvent)
    IWDAttributeInfo attrinfo = wdContext.getNodeInfo().getAttribute(IPrivateTEST_appView.IContextElement.SOURCE);
    wdThis.wdGetAPI().requestFocus(wdContext.currentContextElement(),attrinfo);
    //@@end
  }

4. deploy and run

done

Hope it is clear

Sarbjeet Singh

Former Member
0 Kudos

Hello Prasad,

You can use the following code on the event of the edit button,

IWDAttributeInfo attribute= wdContext.getNodeInfo().getAttribute(IPrivate<ViewName>.IContextElement.<AttributeName>);
	  wdThis.wdGetAPI().requestFocus(wdContext.currentContextElement()<or the node>, attribute); //Sets the Focus on input Field/ Text edit depending on the attribute to which UI element it is bind

Please revert back in cae you have any queries.

Regards,

Ardhendu Sarkar.

pravesh_verma
Active Contributor
0 Kudos

Hi Prasad,

Follow these steps:

1) Create a attribute in the context named view of type IWDView.

2) Write following code in the wdDoModify Funtion:


if(firstTime){
	  wdContext.currentContextElement().setView(view);
 }

3) Now use following code in the onActionEvent of button:


IWDView view = wdContext.currentContextElement().getView();
IWDTextEdit textEdit = (IWDTextEdit)view.getElement("TEXTEDIT_ID");
textEdit.requestFocus();

This will take your cursor to the text edit box.

I hope this solves the issue. Please revert back incase you need further help on this.

Thanks and Regards

Pravesh

Former Member
0 Kudos

There is a method "requestFocus" with which you can call on action of the button click...

Check this thread:

You have to give TextEdit instead of inputField.