Message from "required" Primefaces

Asked

Viewed 1,460 times

1

I have the following scenario :

<h:form id="formValor">

   <p:growl id="growlMessage" showDetail="true" autoUpdate="true"  showSummary="false" />
   <p:tabView id="tabViewVinculo" dynamic="true" widgetVar="tabViewVinculo"...>
       <p:tab id="tab1">
              <p:input id="inputValue" value="{beam.valor}" required="true" />
       </p:tab>
        <p:tab id="tab1=2">
              <p:input id="inputValue2" value="{beam.valor2}"/>
       </p:tab>

   <p:commandButton id="buttonConfirmar" value="Submit" process="@form" validateClient="true" update="growlMessage" .../>
</form>

Having this scenario I would like to customize the message displayed in Growl that comes as follows:

"formValue:inputValue: Validation error: the value is required."

NOTE: I would not like to have changed the component "p:Growl" to "p:message"

**Recital tab 2 active****

2 answers

3

Just use the requireMessage of the component:

<p:inputText id="inputValue" requiredMessage="SUA MENSAGEM" value="{beam.valor}" required="true" />
  • It doesn’t work @Rafael, This "requiredeMessage" is only working in fields that have 'Validator="#{bean.validarIdade}" '

  • This input you posted in your code is correct?

  • in fact my scenario and a little more complex... I edited the question.

  • If it is not working it is for two reasons, it may be that the input is not being processed or its value is not empty.

  • Hello @Rafael, thanks for the attention follow here my solution. blogs.oracle.com/johnc/entry/more_jsf_validation_custom_error

0

In this case, I would put the growl as globalOnly="true" and add messages directly from Bean:

FacesContext context = FacesContext.getCurrentInstance();
    context.addMessage(null, new FacesMessage(
         FacesMessage.SEVERITY_ERROR,     
         "Erro!",
         "Informe um valor para input1."));
  • Thanks, I did this, but today I changed to look better let’s say more elegant since it is a client-side validation. The following link is: https://blogs.oracle.com/johnc/entry/more_jsf_validation_custom_error @info.sistemas

  • In this case, the change is not only for the pointed scenario, but for the whole system.

  • Yes, it is true but I believe I have a better presentation because I do not use Growl for client-side validations, but in this case I have tabview is will be submitted every form presenting the message that there are null mandatory fields was necessary to use Growl.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.