Jahia Template Forum > Custom error messages

0 (0 Good)
0 (0 Bad)

Custom error messages

by  jcp »  2011/06/07 20:07

Hello,

I would like to define custom validation errors messages.

How can I define my message when a field is mandatory (smallText title mandatory)

Is it in the file myTemplate.properties???
myTemplate_myContainer.title.invalidConstraint???=Veuillez saisir le titre

Regards

Jean-Charles

  (jcp)

Number of messages  11
Registration date
0 (0 Good)
0 (0 Bad)

Re: Custom error messages

by  shyrkov »  2011/06/07 20:07

Hello Jean-Charles,

it should be possible by adding:

myTemplate_myContainer.title.invalidConstraint=Veuillez saisir le titre

into your myTemplate.properties (if this one is defined in the templates.xml as the resource bundle of your template set).

Kind regards
Sergiy
  • Re: Custom error messages
    2011/06/07 20:07

    shyrkov Hello Jean-Charles,<br/><br/>it should be possible by adding:<br/><br/>myTemplate_myContainer.title.invalidConstraint=Veuillez saisir le titre<br/><br/>into your myTemplate.properties (if this one is defined in the templates.xml as the resource bundle of your template set).<br/><br/>Kind regards<br/>Sergiy

  • Number of messages  407
    Registration date Jun 7, 2011
    0 (0 Good)
    0 (0 Bad)

    Re: Custom error messages

    by  jcp »  2011/06/07 20:07

    Hello Sergiy,

    my file myTemplate.properties is well defined in template.xml, I use it for rename fields, actionmenus.iconlabels.....

    myTemplate_myContainer.title=Titre - is working
    But
    myTemplate_myContainer.title.invalidConstraint=Veuillez saisir le titre - is not working.

    Is there any other value than quot;invalidConstraint

      (jcp)

    Number of messages  11
    Registration date
    0 (0 Good)
    0 (0 Bad)

    Re: Custom error messages

    by  pap@commaro.com »  2011/06/07 20:07

    Hello Jean-Charles,

    I looked in the code and saw that the mandataory check is done in JahiaField.validate and in this case the message displayed is org.jahia.data.fields.JahiaFields.value.required in JahiaMessageResources.properties . There is unfortunately no possibility to override with custom messages.

    However if this is a hard requirement in your case, you could alternatively remove the mandatory constraint from the CND and define the validations using Struts. There is an example in the test-templates (deployed with Jahia). You can find a validation.xml file, which is a Struts validator file. In the CND you need to set a validator key for the container, e.g.:

    [test_templates:validationFieldsUsingValidator] gt; jnt:container validator='test-tesmplates-validationFieldsUsingValidator'

    and then in the validation.xml of your templates you define for the used validator (which is the form key) the validations:

    Benjamin Papez (pap@commaro.com)

    Number of messages  220
    Registration date
    Contact
    Share
    Feedback

    Get in touch

    Whether you are a current user or if you are just evaluating Jahia, we are here to help.

    Contact us

    Share this page