Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

html:error to print specific error

 
Gaurav Chikara
Ranch Hand
Posts: 412
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All
I have a requirement that I need to print a specific error message which also displays the entered values as a part of error message

e.g. I enter two in a text field and message shall appear

"The value two is invalid"

I know that html:error tag reads message from Application.Resources properties file where we only can specify generic message but here requirement is that I need to throw data also with message

If any Guru can give me some cue that will be of great help

Thanks in advance
:roll:
 
Milan Jagatiya
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah....you can pass text value as a argument in ActionError. i am giving you a code line ...not sure ...but check it out...


and in your properties file put below line...
errors.textboxerror= The value {0} is invalid

hope it works...i
or you can use Validator framewors....it works....
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question gets asked enough that I am sure that somebody has found a "solution". To me it just seems like a bad requirement. The basic idea is that your form shows the fields: say Name, Age, and Weight. If the user enters an invalid value in Weight field the user sees the message "Weight is invalid", or "Weight is not a valid whole number". The user looks at the Weight field and sees that they entered the text "two" so they correct it. If the message just said "The value two is invalid" and they entered "two" in multiple fields they have no idea which one is invalid.

- Brent
 
Gaurav Chikara
Ranch Hand
Posts: 412
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are right Brent
This shall not be an ideal way to display wrongly entered values as part of error messages but we don't control these business users and have to adhrere to what they demand

Thanks a bunch Milan for giving me a hint
It works now
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Milan: How could you do this using the Validator framework?

- Brent
 
Milan Jagatiya
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Brent Sterling:
Milan: How could you do this using the Validator framework?

- Brent


first replace "ActionForm" with "ValidatorForm" in your form bean.
now suppose your text box name is "firstName" and you want to make it mandatory. refer below lines...


check it out.....
[ February 15, 2007: Message edited by: Milan Jagatiya ]
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Milan: I understand how to use the Validator framework. The original poster wanted to have a message like "The value two is invalid". It seems like that example would just be able to print a message like "The field First Name is invalid". As far as I know the Validator framework does not support including the value that the user entered into the validation message. Please correct me if I am wrong.

Gaurav: I would also suggest that using text like "is invalid" is not a good idea. It would be much better if you could show messages that would mean something to the users. Messages like "X is not a valid phone number", "Y is not a valid decimal number", or "Z does not meet the password requirements".

- Brent
 
Gaurav Chikara
Ranch Hand
Posts: 412
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Brent

I agree with you as it seems we can't give specific wrong values entered using validator framework
As far as my case was concerned requirment was that in a text area a comma,seperated list of domains are entered and error message should specifically tell which of the entered values are blacklisted
Thanks
Gaurav
 
Milan Jagatiya
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Brent Sterling:
Milan: I understand how to use the Validator framework. The original poster wanted to have a message like "The value two is invalid". It seems like that example would just be able to print a message like "The field First Name is invalid". As far as I know the Validator framework does not support including the value that the user entered into the validation message. Please correct me if I am wrong.

- Brent

Yeah you are right Brent, The Validator framework does not support including the value that the user entered into the validation message as Gaurav wants but only the specific field name. and that is the right way i think..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic