JSF simple ajax example

Here is a simple AJAX example in JSF (run on Glassfish). Just to note: for sending the value to the bean you use the execute attribute of f:ajax, and for displaying the output from the beans’s getter, you use the render attribute. 1. pom.xml

2. The xhtml page:

Hello from Facelets

3….

JSF – Add OmniFaces to your project

1. In pom.xml [code] <dependency> <groupId>org.omnifaces</groupId> <artifactId>omnifaces</artifactId> <version>2.0</version> </dependency> [/code] 2. You should put your xhtml pages under: [code]src/main/webapp/WEB-INF/faces-views[/code] 3. In your bean for example. Here strange is a xhtml file under the folder stated in point 2: [code] ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext(); ec.redirect(ec.getRequestContextPath() + "strange"); [/code]