Thursday, December 11, 2014

Why my JSF navigation failed - for beginners in JSF

JSF navigation did not work for me with the following content

<!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">
      from page2.xhtml
      <h:commandButton action="home" value="go to home" />
</html>

Caused a standstill since it did not emit any error in logs.

Since <h:commandButton> produces the html <input type='submit' />, it is supposed to be inside a form. So made the correction and it worked.

<!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">
      from page2.xhtml
      <body>
       <h:form>
      <h:commandButton action="home" value="go to home" />
       </h:form>
      </body>
</html>

No comments: