In this Oracle ADF Training tutorial you will learn how creating Oracle ADF Rich Faces components is a common task for implementing dynamic web pages. You might want to create a page where the end user can dynamically add as many rows of input components as necessary. Why limit them to a static number of choices? You can perform many other tasks besides just adding components. You may remove or reorder items, or even change component attributes such as colors.
This video tutorial will show you how to dynamically create Rich Faces components using a managed bean and partial page rendering (PPR).
To gain programmatic access to a Rich Faces component, you’ll need to:
- Set the “binding” attribute of a containing component, such as the <af:form>. When you set the binding attribute to a managed bean property using the property editor, a few things happen – a Java bean is created and registered with the controller (adfc-config.xml). The bean code contains an attribute representing the ADF component. For example, if you bind the <af:form>, the attribute is a RichForm data type, giving you programmatic access to it.
- Decide what user action on the page will invoke the page refresh. For example, you may choose to use a command button. Apply an action listener to the command component (It’s the “actionListener” property) to a method that belongs to the bean created in the first step. This method will take one argument – an ActionEvent – and return “void”. You can now reference the component declared in step #1.
- Implement the code that gets the action done. Remember, you have a complete Oracle ADF API to access all sorts of Ajax-enabled widgets! Use constructors to create objects, and also be sure to add those objects to the component tree. You’ll also need to obtain an instance of the AdfFacesContext to implement partial page rendering(PPR). The addPartialTarget() method takes as its argument a UIComponent to be refreshed when a partial submit occurs.
Below is a quick example of my managed Java bean code snippet:
public class MyBean{
RichForm theForm;
//theForm getters and setters go here…
public void doSomething(ActionEvent e){
RichInputText inputText = new RichInputText();
inputText.setSubmittedValue(“Hello world”);
List children = theForm.getChildren();
children.add(inputText);
AdfFacesContext ctx = AdfFacesContext.getCurrentInstance();
ctx.addPartialTarget(theForm);
}
}
You may view the API documentation at https://download.oracle.com/docs/cd/E17904_01/apirefs.1111/e10684/toc.htm.
Please Share This Knowledge With Others!