Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Struts email error message appearing twice

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cheers
That sorted it. I should have seen it myself

Shaun
 
No more fooling around. Read this tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic