1

So this is my view:

<!DOCTYPE html>
<html xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">
<h:head>
    <title>Welcome</title>
</h:head>
<h:body>
    <h:form id="myForm" prependId="false">
    </h:form>
</h:body>
</html>

And this is the source of the html output:

<!DOCTYPE html>
<html>
    <head>
        <title>Welcome</title>
     </head>
<body>
    <form id="myForm" name="myForm" method="post" action="/6june/index.xhtml"
                  enctype="application/x-www-form-urlencoded">
        <input type="hidden" name="myForm" value="myForm" />
        <input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState"
value="-6073854252721841133:2030478025710553343" autocomplete="off" />
    </form>
</body>
</html>

So why do I get 2 hidden input fields? And what is that value?

Regards.

Koray Tugay
  • 22,894
  • 45
  • 188
  • 319

1 Answers1

0

These two hidden fields are added by the renderer of h:form. They're send with each JSF request and are used by JSF to restore its view when postback (form submit) is performed. The value of the javax.faces.ViewState hidden field is also used as CSRF token.

Adrian Mitev
  • 4,722
  • 3
  • 31
  • 53