Questions tagged [struts-validation]

Use this tag for questions related to validation of data for struts.

Struts Framework provides the functionality to validate the form data. It can be use to validate the data on the users browser i.e. client side as well as on the server side.

For Server side validation of form we can sub class any FormBean with DynaValidatorForm class and for client side validation we can do it using validation-rules.xml with javascript functions enclosed.

146 questions
3
votes
1 answer

Validations in Struts2 for Integer value?

I want to maintain length of contact number(Like mobile number in between 10 and 12 digits number ). When I used String type I got but it allows alphabets along with numbers also. I want to prevent alphabets. How can I do with integer. Below is my…
user3117840
3
votes
1 answer

How to add CSS on Struts 2 form page

In my Struts 2 application I am trying to add CSS style, but it is not displaying on the page. When I click on the submit button two times and after showing validation error only then CSS is displaying. Please tell me what is the resume of this kind…
user2265669
3
votes
1 answer

MobileNo validation Error and datetime validation technique

I am working on Struts 2 application where am trying to provide validation for mobile number of 10 digit number . I am allowing only 10 digit number but even if i am entering 10 digit number it still showing validation error message AND also want…
Arvind
  • 1,548
  • 17
  • 23
2
votes
0 answers

Struts2 Map/Collection Validation

I am trying to do validation on a Map using struts 2. When I click on the submit button, the error message will always appear even though I have inserted a value into the textbox. Is there anyway for it to work? Any help will be much appreciated.…
2
votes
1 answer

Form validation with Struts 2 + Dojo framework

I'm new on Dojo, and I'm trying to validate a form (like the last one of this example : http://dojotoolkit.org/documentation/tutorials/1.6/validation/), using Struts2 tags, but I can't. With a "classic" HTML form (tags , ....) everything is fine,…
Vince
  • 219
  • 1
  • 4
  • 18
2
votes
2 answers

Struts 2 validate field if not empty

There are two fields email and phone number (integer) in a form. The form is validated using the struts validation framework (ActionClass-validation.xml). These two fields are optional, so the user can leave them blank. But if they are not blank the…
Amit Khanna
  • 489
  • 4
  • 16
2
votes
1 answer

How to short-circuit a @CustomValidator?

Consider below sample, which checks if fromDate and toDate are valid dates and if fromDate is less than toDate: @CustomValidator(type = "DateValidator", fieldName = "fromDate", shortCircuit = true), @CustomValidator(type =…
2
votes
2 answers

Struts Regex Validation

I am using struts 1.2. I need to design a validation that reject characters %,/,?,<,>. As you can identify last two characters need to be escaped but I am unable to find any specific rules of regex in struts.
rahul jain
  • 23
  • 5
2
votes
1 answer

How to print a specific actionerror message with Struts2 validation?

When using Struts2 validation, when you put the tag in your JSP, the default behavior is to display all the action errors at that point in the page. Is there a way to display only specific error messages at that point? For example,…
Eric Wilson
  • 57,719
  • 77
  • 200
  • 270
2
votes
1 answer

Difference between validatorform and validator action form

When should we use ValidatorForm, ValidatorActionForm, and their dynamic variants in struts based applications?
MiKe
  • 55
  • 5
2
votes
1 answer

Change Struts Validator default messages

I am new in struts2 . I have created an XML file for validations, but when I test my form I don't get the error messages that I configured in the XML file. instead I get the Struts 2 defaults messages such as this one : invalid field value for…
2
votes
1 answer

Why Struts 2 annotations don't have LongRangeFieldValidator

I was working on validation using annotation in Struts2 and i was quite surprised to see that the annotations does not have a LongRangeFieldValidator where as the validations done using xml does have a LongRangeFieldValidator I tried different ways…
maxx777
  • 1,320
  • 1
  • 20
  • 37
2
votes
1 answer

Struts can't "refresh" value for a disabled field

I have a problem with Struts. The flow is like this: I submit a field with some value but the validation fails because of something. That's okay. After that, I change some stuff on the page and that field becomes disabled. Next time when I…
erik.c
  • 1,342
  • 2
  • 15
  • 27
2
votes
1 answer

Struts 2.3.16 - DefaultActionValidatorManager.loadFile() throws NullPointerException while loading Object-validation.xml

We are upgrading struts from 2.0.11 to 2.3.16. In our code while trying to get DefaultActionValidatorManager.getValidators(getClass(), null), it throws a NullPointerException from DefaultActionValidatorManager.loadFile() while it tries to load…
2
votes
1 answer

Struts 2's XML validation Error

I'm working on Struts2 + Spring Application and used Struts2 XML validation for validate input fields. Validation is working fine for type - "requiredstring",but when I try to validate type - "email" or "int", it is giving this error. please advise…
Roshan
  • 177
  • 2
  • 9
1
2
3
9 10