*
The moose likes Struts and the fly likes Struts email error message appearing twice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts email error message appearing twice" Watch "Struts email error message appearing twice" New topic
Author

Struts email error message appearing twice

shaun nohy
Greenhorn

Joined: Dec 02, 2004
Posts: 3
Hi there,

I am having a problem display the correct error message using struts

Error message is
{0} is an invalid e-mail address. is an invalid e-mail address.

______struts-config.xml contains______
<form-bean name="customerAddressForm"
type="org.apache.struts.validator.DynaValidatorForm" >
<form-property name="id" type="java.lang.String" />
<form-property name="customerId" type="java.lang.String" />
<form-property name="firstName" type="java.lang.String" />
<form-property name="lastName" type="java.lang.String" />
<form-property name="company" type="java.lang.String" />
<form-property name="department" type="java.lang.String" />
<form-property name="businessTypeId" type="java.lang.String" />
<form-property name="addressTypeId" type="java.lang.String" />
<form-property name="address1" type="java.lang.String" />
<form-property name="address2" type="java.lang.String" />
<form-property name="address3" type="java.lang.String" />
<form-property name="city" type="java.lang.String" />
<form-property name="postCode" type="java.lang.String" />
<form-property name="stateprov" type="java.lang.String" />
<form-property name="country" type="java.lang.String" />
<form-property name="phone" type="java.lang.String" />
<form-property name="mobile" type="java.lang.String" />
<form-property name="fax" type="java.lang.String" />
<form-property name="customerEmail" type="java.lang.String" />
</form-bean>
============================================================================
______validation.xml contains______
<form name="customerAddressForm">
<field
property="company"
depends="required">
<arg0 key="customer.company.required"/>
</field>
<field
property="firstName"
depends="required">
<arg0 key="customer.fname.required"/>
</field>
<field
property="lastName"
depends="required">
<arg0 key="customer.lname.required"/>
</field>
<field
property="businessTypeId"
depends="required">
<arg0 key="customer.businessType.required"/>
</field>
<field
property="address1"
depends="required">
<arg0 key="customer.address1.required"/>
</field>
<field
property="address2"
depends="required">
<arg0 key="customer.address2.required"/>
</field>
<field
property="customerEmail"
depends="required,email">
<arg0 key="errors.email"/>
</field>
</form>

============================================================================
______Properties file contains______
customer.company.required=Company
customer.fname.required=First name
customer.lname.required=Last name
customer.address1.required=Address1
customer.address2.required=Address2
customer.country.required=Country
customer.businessType.required=Business Type
errors.email={0} is an invalid e-mail address. along with all other error messages

All other error messages are working correctly
Everything seems to be fine and i think i have followed the examples

Any ideas?
All help will be greatly appreciated

Shaun
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

The arg0 key tag is to specify what to replace {0} with in the error message. You specified the error message itself, so the "second" error listed on your jsp is the real one and the first "{0} is an invalid e-mail address." is the text replacing the second one's {0}.

Make the email's arg0 work like your other validations by specifying what to place in the {0}.


A good workman is known by his tools.
shaun nohy
Greenhorn

Joined: Dec 02, 2004
Posts: 3
Cheers
That sorted it. I should have seen it myself

Shaun
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts email error message appearing twice
 
Similar Threads
why no errors shown for password validation in struts 1.2.4
Email validation does not work
Errors are not getting displayed on JSP when DynaValidatorActionForm is used.
how do u show multiple validation errors at once struts 1.2.4
Struts Validator Configuration