[OmniFaces utilities] The
update()
method updates the given client IDs in the current ajax response. Note that those client IDs should not start with the naming container separator character like :
. This method also supports the client ID keywords @all
, @form
and @this
which respectively refers the entire view, the currently submitted form as obtained by Components#getCurrentForm()
and the currently processed component as obtained by Components#getCurrentComponent()
. Any other client ID starting with @
is by design ignored, including @none
.Method:
Usage:
JSF
Page:
N1:
<h:outputText id="number1Id"
value="#{testAJAXupdate.number1}"/>
<h:form
id="numberFormId">
N2: <h:outputText id="number2Id"
value="#{testAJAXupdate.number2}"/><br/>
N3: <h:outputText id="number3Id"
value="#{testAJAXupdate.number3}"/><br/>
N4: <h:outputText id="number4Id"
value="#{testAJAXupdate.number4}"/><br/>
<h:commandButton value="New
Number" action="#{testAJAXupdate.updateNumbers()}">
<f:ajax/>
</h:commandButton>
</h:form>
JSF
Bean:
import
org.omnifaces.util.Ajax;
...
@Named
@RequestScoped
public class
TestAJAXupdate {
private int number1 = 0;
...
private int number4 = 0;
public void updateNumbers() {
number1 = new Random().nextInt(1000);
...
number4 = new Random().nextInt(1000);
// [call Ajax.update()]
}
//getters
for number 1..4
}
a) programmatically update only the component with ID, number1Id
Ajax.update("number1Id");
b) programmatically update only the components with IDs, number1Id, number2Id, number4Id
Ajax.update("number1Id",
"numberFormId:number2Id", "numberFormId:number4Id");
c) programmatically update only the components with IDs, number2Id, number4Id
Ajax.update("numberFormId:number2Id",
"numberFormId:number4Id");
d) programmatically update the form
Ajax.update("@form");
d) programmatically update the form and the component with ID, number1Id
Ajax.update("number1Id",
"@form");
d) programmatically update the entire page
Ajax.update("@all");
e) programmatically update this
Niciun comentariu :
Trimiteți un comentariu