problem with validation in Java

1

I'm implementing validationBean in my project, and I'm having a hard time validating a field, but apparently everything is fine in the settings I made in my project as you can see:

Package:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-validator</artifactId>
    <version>5.0.1.Final</version>
    <scope>compile</scope>
</dependency>

Look at the field in my entity:

@NotNull
@Column(precision = 10, scale = 2, nullable = false)
private BigDecimal valorImovel;

And see how it is on my page:

<ui:composition template="/WEB-INF/template/LayoutPadrao.xhtml"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui">

    <ui:define name="titulo">Novo produto</ui:define>

    <ui:define name="corpo">
        <h:form>

            <h1>Novo produto</h1>

            <p:messages autoUpdate="true" closable="true" />

            <p:toolbar style="margin-top: 20px">
                <p:toolbarGroup>
                    <p:button value="Novo" />
                    <p:commandButton value="Salvar" id="botaoSalvar" />
                </p:toolbarGroup>
                <p:toolbarGroup align="right">
                    <p:button value="Pesquisa" />
                </p:toolbarGroup>
            </p:toolbar>

            <p:panelGrid columns="2" id="painel"
                style="width: 100%; margin-top: 20px" columnClasses="rotulo, campo">
                <p:outputLabel value="Nome do Imóvel" for="imovel" />
                <p:inputText id="imovel" size="20" maxlength="20" />

                <p:outputLabel value="Descrição do Imóvel" for="descimovel" />
                <p:inputText id="descimovel" size="60" maxlength="80" />

                <p:outputLabel value="Categoria" for="categoria" />
                <p:selectOneMenu id="categoria">
                    <f:selectItem itemLabel="Selecione a categoria" />
                </p:selectOneMenu>

                <p:outputLabel value="Subcategoria" for="subCategoria" />
                <p:selectOneMenu id="subCategoria">
                    <f:selectItem itemLabel="Selecione a subcategoria" />
                </p:selectOneMenu>

                <p:outputLabel value="Valor unitário" for="valorUnitario" />
                <p:inputText id="valorUnitario" size="10" maxlength="10"
                    value="#{cadastroImovelBean.imovel.valorImovel}" />


            </p:panelGrid>
        </h:form>
    </ui:define>
</ui:composition>

This is the piece of code that interests me:

<p:outputLabel value="Valor unitário" for="valorUnitario" />
<p:inputText id="valorUnitario" size="10" maxlength="10"
    value="#{cadastroImovelBean.imovel.valorImovel}" />

Why did not you validate my field?

    
asked by anonymous 22.09.2015 / 17:17

1 answer

1

In order to process all the fields in your panel you need a button.

<p:commandButton value="Salvar" process="painel @this" update="painel"/>

With this he processes his panel and does the validation.

    
22.09.2015 / 20:02