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

Error in Validation XML

 
Atul bvdu
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI All
I am new in struts 2. So sorry if my question is silly.
I am trying to apply validation of the field.
my action class is like this.

com.test.mypackage;
public class UserRegistration extends ActionSupport{
private UserAddressBean useraddressObject;
... setter/getter
}

UserAddressBean clas is like this

com.test.mypackage;
public class UserAddressBean {
Private String addressLine1;
... setter/getter
}

now I am cteating UserRegistration-validation.xml as follows

1. <!DOCTYPE validators PUBLIC "-//Apache Struts//XWork Validator 1.0.3//EN"
2. "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd">
3. <validators>
4. <field name="usermasterbeanObject.userlogin" >
5. <field-validator type="requiredstring"></field-validator>
6. <message>Enter Login Address.</message>
7. </field>
8.</validators>

I am creating this XML under com.test.mypackage folder
Now the problem is
In eclipse it is showing following errors in the XML
a) On line no 4. The content of element type "field" must match "(field-validator)+".
b) On line no 5. The content of element type "field-validator" is incomplete, it must match "(param*,message)".


Please help me to solve the errors.

Thanks

 
Paul Clapham
Sheriff
Posts: 21133
32
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the field-validator element is supposed to contain the message element, then the field-validator element's closing tag should be after the message element, not before it.
 
Atul bvdu
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:If the field-validator element is supposed to contain the message element, then the field-validator element's closing tag should be after the message element, not before it.


Thanks Paul. It worked. Was my mistake. Putted the tags incorrectly.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic