Wie handle h:inputText-Validierung?

Möchte ich einen Fehler angezeigt hat neben den Feldern, die falsch sind. Ich habe den code für meine Seite :

<!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:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">

<ui:composition template="/WEB-INF/templates/basic.xhtml">
    <ui:define name="content">
        <h:form>
            <h:panelGrid columns="3">
                <h:outputText value="Firstname"/>
                <h:inputText id="firstName" value="#{account.firstName}" required="true">
                    <f:validator validatorId="stringAlphaValidator"/>
                </h:inputText>
                <h:message for="firstName" errorStyle="color:red; display:block"/>
                <h:outputText value="Lastname"/>
                <h:inputText id="lastName" value="#{account.lastName}" required="true">
                    <f:validator validatorId="stringAlphaValidator"/>
                </h:inputText>
                <h:message for="lastName" errorStyle="color:red; display:block"/>
                <h:outputText value="Login"/>
                <h:inputText id="login" value="#{account.login}" required="true">
                    <f:validator validatorId="stringAlphaValidator"/>
                </h:inputText>
                <h:message for="login" errorStyle="color:red; display:block"/>
                <h:outputText value="Password"/>
                <h:inputText id="password" value="#{account.password}" required="true">
                </h:inputText>
                <h:message for="password" errorStyle="color:red; display:block"/>
                <h:outputText value="Address"/>
                <h:inputText id="address" value="#{account.address}" required="true">
                    <f:validator validatorId="stringAlphaNumericValidator"/>
                </h:inputText>
                <h:message for="address" errorStyle="color:red; display:block"/>
                <h:outputText value="Email"/>
                <h:inputText id="email" value="#{account.email}" required="true">
                    <f:validator validatorId="emailAddressValidator"/>
                </h:inputText>
                <h:message for="email" errorStyle="color:red; display:block"/>
            </h:panelGrid>
            <h:commandButton value="Register"/>
            <h:messages globalOnly="true"/>
        </h:form>
    </ui:define>
</ui:composition>
</html>

Wenn ein Feld leer ist und ich drücke die Register - Taste, bekomme ich (hier alle Felder sind leer):

Wie handle h:inputText-Validierung?

(sorry, der Fehler ist in Französisch. Ich weiß nicht, ob es kommt aus meinem eclipse-Sprache oder meinem tomcat-server)

Wusste ich nicht, Schreibe dies ! Dies ist ein text, dass mein Programm schreibt auf seine eigene irgendwie... Wie Entferne ich diese ?

Dies ist auch ein register, Seite, ich möchte noch hinzufügen, dass meine DB den user (wenn die Felder rechts) und ändern Sie dann auf der Seite mit der Aktion login. Wie kann ich eine Methode aufrufen zu tun, bevor es änderungen auf der Seite ?

Wenn du mehr sehen müssen code, wie der validator-Klassen, kann ich es hinzufügen.

InformationsquelleAutor Elfayer | 2014-01-13
Schreibe einen Kommentar