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!

How to set focus on readonly textbox

ShahDec 5 2011 — edited Dec 5 2011
Hi All,
I need to set the focus on readonly textbox in managed bean.I have read from the af:inputtext documentation , it is written that:-
whether the control is displayed as an editable field or as an output-style text control. Unlike a disabled component, a readonly component is able to receive focus.
I have tried using these code but it didn't help me :-

*1. FacesContext context = FacesContext.getCurrentInstance();
String inputId="f1:p1:d2:it3";
ExtendedRenderKitService service = Service.getRenderKitService(context, ExtendedRenderKitService.class);
*service.addScript(context, "comp = AdfPage.PAGE.findComponent('"+inputId+"');\n" +*
*"comp.focus()");*

*2. FacesContext context = FacesContext.getCurrentInstance();*
ExtendedRenderKitService erks =
org.apache.myfaces.trinidad.util.Service.getRenderKitService(context, ExtendedRenderKitService.class);
String script ="AdfPage.PAGE.findComponent('it3').focus();";
erks.addScript(context, script);

*3. FacesContext context = FacesContext.getCurrentInstance();*
String textId = "it3"; //popup.getClientId(context);
StringBuilder script = new StringBuilder();
script.append("var iptext = AdfPage.PAGE.findComponent('").append(textId).append("'); ").append("iptext.focus() ");
ExtendedRenderKitService erks = Service.getService(context.getRenderKit(),
ExtendedRenderKitService.class);
erks.addScript(context, script.toString());

I need to set the focus in it3 which is inside the dialog "d2" , and "d2" is inside popup "p1" and "p1" is inside form "f1".
Please suggest how can i achieve this.??
Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 2 2012
Added on Dec 5 2011
3 comments
500 views