How to declaratively instruct ADF Faces RC to partially refresh other components upon an event

Share this on .. Tweet about this on TwitterShare on LinkedIn0Share on Facebook0Share on Google+0Email this to someoneShare on Tumblr0Buffer this page


ADF Faces RC has built in support for AJAX and Partial Page Refresh. Through the autoSubmit and partialSubmit attributes, we can indicate that a value change or an action (button or link click) should trigger an asynchronous request (PPR request). Through the partialTriggers attribute, we can configure components to be refreshed in any PPR request that is initiated by the a component whose Id is listed in the partialTriggers attribute. So you can say that through the partialTriggers attribute, we register a component as PPR listener on all components listed in the attribute value.

Sometimes, developers would like to be able to do it the other way round. To specify on a component X which other components should be refreshed when X is initiating a PPR request. In this article, we will discuss a method for doing exactly that.We will use a very simple example of an outputText that displays the value of the counter property of a managed bean. The page contains a commandLink. When this link is clicked, the counter is incremented and we would like the outputText to be (partially) refreshed.

The usual approach for this: set partialSubmit to true for the link and include the commandLink component’s ID value in the partialTriggers attribute of the outputText:

        <af:panelLabelAndMessage id="counterLabel" label="Counter"
          <af:outputText id="counter" value="#{CounterBean.counter}"
                         <strong>partialTriggers=&quot;increment&quot;</strong> /&gt;
        &lt;af:commandLink <strong>id=&quot;increment&quot;</strong> text=&quot;Increase and Refresh Counter&quot;

In this case, we will turn that around. The instruction to refresh the outputText when the link is activated is added to the commandLink.

        &lt;af:panelLabelAndMessage id=&quot;counterLabel&quot; label=&quot;Counter&quot;
          &lt;af:outputText id=&quot;counter&quot; value=&quot;#{CounterBean.counter}&quot;/&gt;
        &lt;af:commandLink <strong>id=&quot;increment&quot;</strong> text=&quot;Increase and Refresh Counter&quot;
          &lt;af:setPropertyListener from=&quot;counter&quot;

The mechanism used in this approach is a generic PartialTargetManager with a setPartialTarget method that accepts a string that should hold the id for the component that should be refreshed. The setPropertyListener will fire when the link is activated (type=’action’) and will pass the string value "counter" (the id of the outputText component) to this setter method.

The PartialTargetManager bean is implemented as follows:

public class PartialTargetManager {
    public void setPartialTarget(String componentId) {
        UIComponent component = FacesContext.getCurrentInstance().getViewRoot().findComponent(componentId);
        if (component!=null) {
          AdfFacesContext context = AdfFacesContext.getCurrentInstance();

The setPartialTarget method tries to find the component specified in the ViewRoot. When found, the component is passed to the list of partial targets in the AdfFacesContext.

The bean is configured in faces-config.xml:


The Counter bean is trivial:

public class Counter {

    private Integer counter =0;

    public Integer getCounter() {
        return counter;

    public void increaseCounter(ActionEvent event) {

When we run the page, the outputText and its label are displayed as well as the action link. Clicking the action link will lead to an increased value in the counter value – through PPR that was declaratively instructed from the perspective of the link to refresh the outputText.


Download JDeveloper 11g sources

Share this on .. Tweet about this on TwitterShare on LinkedIn0Share on Facebook0Share on Google+0Email this to someoneShare on Tumblr0Buffer this page

About Author

Lucas Jellema, active in IT (and with Oracle) since 1994. Oracle ACE Director for Fusion Middleware. Consultant, trainer and instructor on diverse areas including Oracle Database (SQL & PL/SQL), Service Oriented Architecture, BPM, ADF, JavaScript, Java in various shapes and forms and many other things. Author of the Oracle Press books: Oracle SOA Suite 11g Handbook and Oracle SOA Suite 12c Handbook. Frequent presenter on conferences such as JavaOne and Oracle OpenWorld. Presenter for Oracle University Celebrity specials.

1 Comment

  1. Can this be done cross two pages? The use case is when the command link is on a search page while the counter or a ui component is on the edit page needs to be refreshed after navigated from the search to edit page.