1

My validator seem to resume to false once I'm not in the field anymore, why is that ? I thought it was because everytime I blur a field a new request is made thus losing the data of validators but I'm not sure it's the case. I've visual icons that reflect if the validation of a field passed. However when one of my validation test passed the submit button is available, not when all of them passed. Even though you can see at the bottom of the picture that the result of the condition is false. Which is odd because it's the exact same condition reversed. validation_fail

for example here you see every field validation passed indicated by the green icon, (the submit button is available but it would have been available as soon as 1 field test passed). And under the submit button is the values of the different validators.

                <p:commandButton value="Submit" id="submit" action="#{subscribeUser.inscrireUser}"  icon="ui-icon-disk" 
                disabled="#{(!usernameValidator.ok  and !passwordValidator.ok and !emailValidator.ok)}" />      

and here are some fields:

            <tr><td>
            <h:outputLabel for="username">#{registering.Username}: </h:outputLabel></td><td>
            <p:inputText id="username" value="#{subscribeUser.user.username}" 
                validator="#{usernameValidator.validate}">
                <f:passThroughAttribute name="required" value="true"/>
                <f:ajax event="blur" render="usernameCheck usernameMessage submit vals"></f:ajax>
            </p:inputText></td><td>
            <h:panelGroup id="usernameCheck">
                <h:graphicImage library="images/icons" name="failed_indicator.png" rendered="#{usernameValidator.isIndicatorVisible.usernameFailed}"></h:graphicImage>
                <h:graphicImage library="images/icons" name="success_indicator.png" rendered="#{usernameValidator.isIndicatorVisible.usernameSuccess}"></h:graphicImage>
            </h:panelGroup></td><td>
            <span class="error"><h:message id="usernameMessage" for="username"/></span></td>
            </tr>

            <tr><td>
            <h:outputLabel for="email">#{registering.Email}: </h:outputLabel></td><td>
            <p:inputText id="email" required="true" value="#{subscribeUser.user.email}" 
                validator="#{emailValidator.validate}"
                requiredMessage="#{registering.reqEmail}">
                <f:passThroughAttribute name="required" value="true"/>
                <f:passThroughAttribute name="type" value="email"/>
                <f:passThroughAttribute name="maxlength" value="100"/>
                <f:ajax event="blur" render="emailCheck emailMessage submit vals"></f:ajax>

            </p:inputText></td><td>
             <h:panelGroup id="emailCheck">
                <h:graphicImage library="images/icons" name="failed_indicator.png" rendered="#{emailValidator.isIndicatorVisible.emailFailed}"></h:graphicImage>
                <h:graphicImage library="images/icons" name="success_indicator.png" rendered="#{emailValidator.isIndicatorVisible.emailSuccess}"></h:graphicImage>
            </h:panelGroup> </td><td>
            <span class="error"><h:message id="emailMessage" for="email"/></span></td>
            </tr>

When using this:

<p:commandButton value="Submit" id="submit" action="#{subscribeUser.inscrireUser}"  icon="ui-icon-disk" 
                disabled="#{(!usernameValidator.ok  and !passwordValidator.ok and !emailValidator.ok)}" />  

<h:outputText id="vals" name="vals" value="#{usernameValidator.ok}  and #{passwordValidator.ok} and #{emailValidator.ok}
                    = #{usernameValidator.ok  and passwordValidator.ok and emailValidator.ok}"></h:outputText>

When blurring a field, the correct value of the field validation is put, but others automatically change to false. Why is that happening ?

Ced
  • 15,847
  • 14
  • 87
  • 146
  • 1
    To avoid the obvious, is the bean view scoped? – BalusC May 21 '15 at 21:39
  • Thanks for stating the obvious it works now. I thought the validation was redone automatically on each request ? Kinda like how a bean user would get the variables username password and email...and why don't you post as answer. Gotta get some karma. – Ced May 22 '15 at 00:28
  • And by the way you said in this topic http://stackoverflow.com/questions/30379541/jsf-spring-security-integration-how-to-configure-the-datasource-jdbc that spring and jsf are competiting technologies and shouldn't be used together. However I'm using spring security to handle the security and this post confused me a bit on what I could and couldn't do. I posted a topic today ( I edited it now so if you have seen it just check the main question please ) http://stackoverflow.com/questions/30379541/jsf-spring-security-integration-how-to-configure-the-datasource-jdbc and Idk if the tuto can be used – Ced May 22 '15 at 00:47
  • Carefully read http://stackoverflow.com/questions/18744910/using-jsf-as-view-technology-of-spring-mvc once again. Spring MVC != Spring Security. – BalusC May 22 '15 at 05:59

0 Answers0