My JSF Books/Videos My JSF Tutorials OmniFaces/JSF PPTs
JSF 2.3 Tutorial
JSF Caching Tutorial
JSF Navigation Tutorial
JSF Scopes Tutorial
JSF Page Author Beginner's Guide
OmniFaces 2.3 Tutorial Examples
OmniFaces 2.2 Tutorial Examples
JSF Events Tutorial
OmniFaces Callbacks Usages
JSF State Tutorial
JSF and Design Patterns
JSF 2.3 New Features (2.3-m04)
Introduction to OmniFaces
25+ Reasons to use OmniFaces in JSF
OmniFaces Validators
OmniFaces Converters
JSF Design Patterns
Mastering OmniFaces
Reusable and less-verbose JSF code

My JSF Resources ...

Java EE Guardian
Member of JCG Program
Member MVB DZone
Blog curated on ZEEF
OmniFaces is an utility library for JSF, including PrimeFaces, RichFaces, ICEfaces ...

[OmniFaces Utilities] - Find the right JSF OmniFaces 2 utilities methods/functions

Search on blog

Petition by Java EE Guardians

Twitter

marți, 20 ianuarie 2015

[OmniFaces utilities (2.0)] Programmatically update the given client IDs in the current ajax response


[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, number1Idnumber2Idnumber4Id

Ajax.update("number1Id", "numberFormId:number2Id", "numberFormId:number4Id");

c) programmatically update only the components with IDs, number2Idnumber4Id

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

Ajax.update("@this");

API GH 

Niciun comentariu :

Trimiteți un comentariu

JSF BOOKS COLLECTION

Postări populare

OmniFaces/JSF Fans

Follow by Email

Visitors Starting 4 September 2015

Locations of Site Visitors