If JSF 2.0 is compared to its previous version JSF 1.2, there are more functionality are added

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://java.sun.com/jsf/html" > < h: head > < title > Sample JSF Application </ title > </ h: head > < h: body > < h: form > Enter your Name < h:inputText value = "#{demoBean.name}" required = "true" /> < h:commandButton value = "Submit" action = "welcome" /> </ h: form > </ h: body > </ html >

welcome.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://java.sun.com/jsf/html" > < h: head > < title > Welcome Page </ title > </ h: head > < h: body > Hello #{demoBean . name} </ h: body > </ html >

DemoBean.java

< html xmlns = "http://www.w3.org/1999/xhtml" xmlns:h = "http://java.sun.com/jsf/html" >

View Tree of index.xhtml page

Phase 1 : Create / Restore View

Phase 6 : Render the View

Phase 3: Apply values from User to View

Phase 4: Validate the values

Phase 5: Fetch New View

Update : I put new post for Why should I learn JSF

I put new post for Understanding Java Server Faces 2.0 Part 2





Comments are welcomed







