Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts email error message appearing twice

 
shaun nohy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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}.
 
shaun nohy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cheers
That sorted it. I should have seen it myself

Shaun
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic