My sample form is given blow. When I click on the "Login" button, validation message is shown for the userName field as immediate="true". And when I click on the "Forgot Password" button, page is directed to my success page. As immediate=true present for button and userName input field, I am expecting required field validation on user name. But this is not the case.
Am I missing anything in this code?
<h:form>
<h:panelGrid columns="3">
<h:outputText value="User Name" for="userName" />
<h:inputText id="userName" value="#{myBean.userName}" required="true"
requiredMessage="User Name is required" immediate="true"
binding="#{myBean.userNameText}"></h:inputText>
<h:message for="userName" />
<h:outputText value="User Password" for="userPwd" />
<h:inputText id="userPwd" value="#{myBean.userPwd}" required="true"
requiredMessage="User Password is required"
binding="#{myBean.userPwdText}">
</h:inputText>
<h:message for="userPwd" />
<h:commandButton value="Login" action="#{myBean.action()}"></h:commandButton>
<h:commandButton value="Forgot Password" action="#{myBean.action()}"
immediate="true"></h:commandButton>
</h:panelGrid>
</h:form>