Back Forum Reply New

How to populate {0} {1} in messages.properties strings in validation

Hello,

I have another newby Spring Web flow question.

How do I populate the {0} and {1} value in the following?

I have a messages.properties file with the following:

Code:
myForm.myTerm.range=The term must be between {0} and {1}

And the following in my validate method:Code:    MessageContext messages = context.getMessageContext();

    if (this.getMyTerm() != null) {       if (this.getMyTerm() lt;= 0 || this.getMyTerm() gt; 10) {       messages.addMessage(new MessageBuilder().error().source(quot;myTermquot;).        code(quot;myForm.myTerm.rangequot;).build());       }    }sprin...#view-messages

use resolvableArgs function.

You can use:Code:
messages.addMessage(new MessageBuilder().error()          .source(quot;myTermquot;).code(quot;myForm.myTerm.rangequot;)          .args(new Object[]{value0, value1}).build());Thank you both!
¥
Back Forum Reply New