How to Import JavaScript Libraries

Using ADF Faces Architecture 3-7 af:commandButton af:outputText id=greeting value= clientComponent=true Because the outputText component will now have client-side representation, the JavaScript will be able to locate and work with it.

3.5 Locating a Client Component on a Page

When you need to find a client component that is not the source of an event, you can use the AdfUIComponent.findComponentexpr method. This method is similar to the JSF UIComponent.findComponent method, which searches for and returns the UIComponent object with an ID that matches the specified search expression. The AdfUIComponent.findComponentexpr method simply works on the client instead of the server. Example 3–8 shows the sayHello function finding the outputText component using the component’s ID. Example 3–8 Finding a Client Component Using findComponent function sayHelloactionEvent { var component=actionEvent.getSource; Find the client component for the greeting af:outputText var greetingComponent=component.findComponentgreeting; Set the value for the outputText component greetingComponent.setValueHello World } Instead of using the AdfUIComponent.findComponentexpr method, you can use the AdfPage.PAGE.findComponentByAbsoluteIdabsolute expr method when you know the absolute identifier for the component, but you dont have a component instance to call AdfUIComponent.findComponentexpr on. AdfPage.PAGE is a global object that provides a static reference to the pages context object. However, if the component you are finding is within a naming container, then you must use AdfUIComponent.findComponent. For more information, see Section 3.5.1, What You May Need to Know About Finding Components in Naming Containers.

3.5.1 What You May Need to Know About Finding Components in Naming Containers

If the component you need to find is within a component that is a naming container such as pageTemplate, subform, table, and tree, then instead of using the AdfPage.PAGE.findComponentByAbsoluteIdabsolute expr method, use the AdfUIComponent.findComponentexpr method. The expression can be either absolute or relative. Note: There is also a confusingly named AdfPage.PAGE.findComponentclientId method, however this function uses implementation-specific identifiers that can change between releases and should not be used by page authors.