Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Set focus on input text with server side javascript

ShaheApr 8 2013 — edited Apr 10 2013
Hello,

I have a situation where I need to set the focus on an input text on a particular action.

I searched the net and I found examples on how to set the focus using server side javascript, here is my code:

-------------------------------------------------------------------------------------
int index = ( the index of the added record. );
StringBuilder script = new StringBuilder();
script.append("var textInput = ");
script.append("AdfPage.PAGE.findComponentByAbsoluteId");
script.append ("('pt1:t2:"+index+":it2');");
script.append("alert(textInput);");
script.append("if(textInput != null){");
script.append("textInput.focus();");
script.append("}");

ADFUtils.writeJavaScriptToClient(script.toString());
-------------------------------------------------------------------------------------

the input text is located in a table, the first column of my editable table, the thing is; when the user adds a new record in the table I want to set the focus on the added record's first column's input text.
My Table id is "t2" and the input text's id is "it2" and "pt1" is the page template id.

the problem is that alert on the 4th line is return "null".

Anybody can give me the reason why? or give me another solution on how to do this.

Thanks,
Shahe
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 8 2013
Added on Apr 8 2013
1 comment
394 views