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

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

 

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:

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

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:

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:

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.

Resources

Download JDeveloper 11g sources componentToComponentPPR.zip .

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值