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 focus on an ADF component using a javascript

713536Apr 2 2010 — edited Apr 6 2010
I have following popup defined in my jspx page:

<af:popup id="myPopup" clientComponent="true"
contentDelivery="lazyUncached" eventContext="launcher">
<af:dialog title="Popup Title"
clientComponent="true" id="d2"
type="okCancel"
dialogListener="#{myBean.dialogListener}">
<af:panelFormLayout maxColumns="1"
fieldWidth="80%"
labelWidth="20%"
id="pfl12">
<af:inputText label="Text1"
secret="true" id="it53" immediate="true"
binding="#{myBean.text1}"/>
<af:selectBooleanCheckbox id="ckBox" label="Extra Keys" text="Take focus to Text2"
autoSubmit="true" value="#{myBean.selected}"/>
<af:inputText label="Text2"
secret="true" id="it54" immediate="true"
binding="#{mtBean.text2}"/>
</af:panelFormLayout>
</af:dialog>
</af;popup>

After the popup is rendered the focus is set to RichInputText with id="text1" by default. After I click on the checkbox, I need to focus on the RichInputText with id="text2".

Inside the value change listener of the RichSelectBooleanCheckbox, I am using following javascript and adding it into the FacesContext for setting the focus on the text field:
String js = "comp = AdfPage.PAGE.findComponent('" + clientId + "');\n" + "comp.focus();";

Here the clientId variable is retrieved by calling the getClientId() method on the binding variable of text2. However I am not able to set the focus on the desired component.

Am I missing anything here? Is there any other option other than using javascript to achieve the goal?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 4 2010
Added on Apr 2 2010
3 comments
4,196 views