0

I am studying a system that uses jsf and primefaces. I expected that this snipped showed an error close a the input but the error appears as a message in the upper left corner of screen.

<h:form>

    <div class="col-md-4"> 
        <p:outputLabel  value="Rua:"></p:outputLabel>
        <p:inputText id="rua"  value="#{enderecoFace.endereco.rua}"   >
            <p:message for="rua" ></p:message>
            
        <f:validateLength  minimum="3" maximum="3" />

    <h:message  for="rua" style="color:red"></h:message>
        </p:inputText>
        
    </div>

What can be going on?

Diego Alves
  • 2,462
  • 3
  • 32
  • 65

1 Answers1

1

First change the position of your p:message. It should not be a child of the input component. So do:

<p:outputLabel value="Rua:" />
<p:inputText id="rua" value="#{enderecoFace.endereco.rua}">            
    <f:validateLength minimum="3" maximum="3" />
    <!-- NOT here -->
</p:inputText>
<p:message for="rua" /> <!-- but here instead -->

And make sure the message component is updated by the component that invokes the action (like a p:commandButton).

See also:

Messages in the top right (you also mentioned left) corner could be caused by a p:growl. Check you template and optionally set the growl properties to your needs.

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102