on 03-03-2008 12:46 PM
Hi Friends,
I need to set the Cursor to the Input Field when ever the page is being loaded,so that the user enters directly into the Input Field without using a Mouse.
Please help me out to find a solution for this issue.
Thanks and regards,
Chandrashekar.
Hi,
Use any of the following
public static void wdDoModifyView(IPrivateTestCompView wdThis, IPrivateTestCompView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
{
//@@begin wdDoModifyView
if(firstTime)
{
// replace the following nodeelement and attribute with yours
IWDInputField inputField = (IWDInputField)view.getElement("Your InputField ID";
//inputField.requestFocus(nodeElement, attribute)
//Ex
IWDAttributeInfo attribute = wdContext.getNodeInfo().getAttribute("Name");
inputField.requestFocus(wdContext.currentContextElement(), attribute);
}
//@@end
}
Or in any action handler or init as follows
IWDAttributeInfo attribute = wdContext.getNodeInfo().getAttribute("Name");
wdThis.wdGetAPI().requestFocus(wdContext.currentContextElement(), attribute);
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ayyaparaj,
Can you please elaborate the Code you had sent.
Actually my code is:
IWDInputField input = (IWDInputField)view.getElement("<IDName>");
input.requestFocus();
I am writing this in wdDoModifyView() itself.
But i am still unable to do so.
Infact my code is working but sometimes very rarely my cursor gets placed in the Field.Say out of 10 times it happens for about twice.
What might be the problem.
Please help me out to find a solution.
Regards,
Chandrashekar.
Hi,
Following are the things you need to consider
From the docs
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.
<pre>
IWDAttributeInfo attribute
= wdContext.nodeXYZ().getNodeInfo().getAttribute(
IPrivateMyView.IXYZElement.ABC);
wdThis.wdGetAPI().requestFocus(wdContext.currentXYZElement(), attribute);
</pre>
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 <code>DropDownByKey</code> or some fancy new editor with
"guess what I want" value help, the code to request focus remains unaffected.
Regards
Ayyapparaj
Hi,
Use requestFocus() method of the UI element or the contextElement to get the focus on the inputField.
thanks & regards,
Manoj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
98 | |
11 | |
11 | |
10 | |
10 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.