| Author |
Struts Validator Message Arguments
|
Dan Ludwig
Greenhorn
Joined: Jun 05, 2004
Posts: 18
|
|
I think it's great that I can compose validation failure messages using a resource properties file, passing in different resource keys as arguments like so: <field property="fieldname" depends="required"> <msg name="reqmsg" key="form.add.errors.fieldname.required" /> <arg0 key="form.fieldname.display" /> </field> ..Which has a properties resource that results in the message: <span class="error-field">Field Name</span> is required. So, what if I want to use a runtime value as a message argument? Is that possible with the Struts Validator? How is it accomplished? For example, my target message would be something like: The <span class="error-field">Username</span> <span class="error-value">root</span> is already taken by another user. Please choose a different <span class="error-field">Username</span>. ... The message properties would look something like: user.add.errors.username.taken=The <span class="error-field">{0}</span> <span class="error-value">{1}</span> is already taken by another user. Please choose a different <span class="error-field">{0}</span>. But, I can't find any documentation on how to configure validation.xml to pass the argument in from a FormBean property. Am I chasing my tail, or is this possible? Thanks, Dan
|
 |
 |
|
|
subject: Struts Validator Message Arguments
|
|
|