controller - Understand JSF action -


i start jsf 2, create xhtml page index.xhtml, page have button:

<h:commandbutton value="submit" action="welcome" /> 

and create page welcome.xhtml.

but when view source of index.xhtml, don't see "link" index.xhtml file welcome.xhtml file, how jsf can pass index welcome?

when view source, source page is:

<!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"><head></head><body lang="en"> <form id="j_idt5" name="j_idt5" method="post" action="/test/index.xhtml" enctype="application/x-www-form-urlencoded"> <input type="hidden" name="j_idt5" value="j_idt5" /> <input type="submit" name="j_idt5:j_idt6" value="submit" /><input type="hidden" name="javax.faces.viewstate" id="javax.faces.viewstate" value="-5517223312856481273:-1605099621977497303" autocomplete="off" /> </form></body>  </html> 

i realy don't see "link" or action "welcome", in hidden field, see viewstate auto generate , change when refesh page. don't see javascript code load welcome page.

after run <h:link>, think, when first time, jsf read index.xhtml , show it, after submit press, jsf read index.xhtml , action of button , show welcome page.

from mkyong site - http://www.mkyong.com/jsf2/jsf-2-0-hello-world-example/

in jsf 1.x, had declare “navigation rule” in “faces-config.xml“, tell page display when button clicked. in jsf 2.0, can put page name directly in button’s “action” attribute. simple navigation, it’s more enough, but, complex navigation, still advised use “navigation rule” in “faces-config.xml“.

i suggest read tutorials jsf 2 or buy book -> give me jsf 2.0 tutorial


Comments

Popular posts from this blog

Python Kivy ListView: How to delete selected ListItemButton? -

asp.net mvc 4 - A specified Include path is not valid. The EntityType '' does not declare a navigation property with the name '' -