• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

validation message

 
sarah jj
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

i am developing a web application for the first time using
MyEclipse7.0 IDE
hibernate 3
struts 1.1
MyEclipse Tomcat 6
i want to have a <html:form> for my jsp of connection which contains textfields userName, password...and it must invoke on submit the action /userLogin which is already mapped in struts-config.xml there are two possibilities
either to have an other jsp page in success
or to redirect to the same jsp if there are some missing or invalid fields

here my code

messagesRessources.properties


userLogin.jsp(i just put the code of my form)


userLoginForm(it contains all getter and setter method and here is the validate method)

finally for userLoginAction it just contains the different mapping values

my problem is instead of having a message error in front of the missing field it just cause an exception as if i add it to validator-rules.xml
please could you help me to display these messages??
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What exception?
 
Prakash Mani - Attur
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Validator should work with 1.1.. may be the problem is yours.. It can be forgot to add plugin element in struts-config.xml.. but i should not guess like this.. if you have given us the exception message then it might be more useful..

Also I will tell your requirement..
Use html:errors tag in the jsp file at the start of your html:form tag....
for e.g it may be like this... If this is not the better approach please tell me how to approach it better..


Also you can display the errors in the list form by adding the below lines in property file..But some say adding html contents in property file is bad idea, if you too think so use custom tags..

 
sarah jj
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

this is the exception that i get when i skip the textfield "Username"


last night i tried the plug-in in struts-config.xml but always the same exception


and my new messagesRessources.properties

by the way i tried your solution

but it invoked an error which is "Globals cannot be resolved" could you please explain what did you mean by adding this tag and what's the problem with it

here is my jsp page if it may help you


and i hadn't change anything else except the validation.xml that i did add
 
Prakash Mani - Attur
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
errors.add("username",new ActionMessage("error.userName.required"));


instead of the above try the below

..
also you need not to use GLOBALS ERROR_KEY, simply use html:errors tag in the form.. if you still want to use it import this package
org.apache.struts.GLOBALS
 
sarah jj
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you so so much
i just put <html:errors/> and change ActionMessage with ActionError and finally it works
thanks again
 
Rajesh Vraj
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Actionerror instead of action message worked for me.

thanks alot.

raj
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic