Partial view updates

Partial view updates

In this topic, we will discuss the Partial view updates in RichFaces.

We can use the rendered attribute to specify which components to render for an Ajax update. The render attribute can point to an id identifier of a specific component to update. Components can also be identified through the use of Expression Language (EL).

The render attribute accepts the following keywords:

KeywordFunction
@allIt is used to update every component.
@noneIt is used for no components to be updated.
@thisIt is used for requesting components with the execute attribute is updated.
@formIt is used to update the form that contains the requested component.
@regionThe region that contains the requesting component is updated. Use the <a4j:region> component as a wrapper element to specify regions.

We should use the <a4j:outputPanel> component by setting ajaxRendered=”true”.

The <rich:message> and <rich:messages> components are based on the <a4j:outputPanel> component and as such will also always be updated. To override this behavior, use the limitRender=”true” setting on the requesting component.

// index.xhtml

<?xml version='1.0' encoding='UTF-8' ?>  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<html xmlns="http://www.w3.org/1999/xhtml"  
xmlns:h="http://xmlns.jcp.org/jsf/html"  
xmlns:a4j="http://richfaces.org/a4j">  
<h:head>  
<title>Partial View Update</title>  
</h:head>  
<h:body>  
<h:form>  
<h:outputText value="Enter Text "></h:outputText>  
<h:inputText id="name1" value="#{user.name}">  
<a4j:ajax event="keyup" render="name2"></a4j:ajax>  
</h:inputText>  
</h:form>  
<br/>  
<br/>  
<a4j:outputPanel ajaxRendered="true">  
<h:outputText value="#{user.name}"></h:outputText>  
</a4j:outputPanel>  
</h:body>  
</html>  

// User.java

import javax.faces.bean.ManagedBean;  
import javax.faces.bean.RequestScoped;  
@ManagedBean  
@RequestScoped  
public class User {  
String name;  
public String getName() {  
return name;  
}  
public void setName(String name) {  
this.name = name;  
}  
}  
Partial view updates

In this topic, we will learned about the Partial view updates in RichFaces. To know more Click Here.

This Post Has One Comment

Leave a Reply