Announcement Announcement Module
Collapse

Spring Modules forum decommissioned in favor of Spring Extensions

As the Spring Modules project has been replaced by the Spring Extensions (http://www.springsource.org/extensions) project, this forum has been decommissioned in favour of Spring Extensions one at:
http://forum.springsource.org/forumdisplay.php?f=44

Please see the Spring Extensions home page for a complete list of current projects in Java, .NET and ActionScript. You can also propose one if you want.

Cheers,
Costin Leau
SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
http://twitter.com/costinl
See more
See less
How to override validation rule's msg? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to override validation rule's msg?

    My validation.xml looks like so:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE form-validation PUBLIC 
        "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1//EN" 
        "http://jakarta.apache.org/commons/dtds/validator_1_1.dtd">
    
    <form-validation>
        <formset>
            <form name="question">
    			<field property="content" depends="required,mask">
    				<arg0 key="labels.question" />
    				<var>
    					<var-name>mask</var-name>
    					<var-value>^.*\?$</var-value>
    				</var>
    			</field>
            </form>
        </formset>
    </form-validation>
    I tried two things (both didn't work):
    1. <msg name="errors" key="errors.not.question" /> tag right before <arg0>
    2. Creating a new rule that was based on mask rule (via depends) with the msg I wanted.

    What am I doing wrong? I have the default errors.invalid and errors.required in errors_en.properties file.

  • #2
    Messages can be over-ridden by nesting a <msg> element in your <field> element as shown in the following example:

    <field property="content" depends="required,mask" >
    <msg name="required" key="error.your.required" />
    ....
    </field>

    where your new message is defined in your properties resource file using the specified key error.your.required.

    Comment

    Working...
    X