Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

validate method is not being called

 
Shawn Hanna
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I'm new to the struts framework. I'm using struts 1.1.
I set up a validate method in my ConnectionDetailForm but when I run /ProccessAddNew action the form the validate() method is never called.

Below is my struts-config.xml file.

The Form connectionDetails has the validate method. The way it is supposed to work is that when I add a new Connection with a blank alias the validation should kick in and show me a message.

Below is the ConnectionDetailsForm contents.

Can you help me? the validate method is completley ignored.
Shawn

 
Matt Raible
author
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You form needs to extend org.apache.struts.validator.ValidatorForm.
 
Shawn Hanna
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried it. I changed the ActionForm to ValidatorForm. I get the same results, the validator method is not called.

Shawn
Any other ideas I could try?
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I set up a validate method in my ConnectionDetailForm but when I run /ProccessAddNew action the form the validate() method is never called.


Change "/ProccessAddNew" to run "/ProcessAddNew"
 
Sunil Manheri
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to give the input parameter also:



[ October 27, 2004: Message edited by: Sunil Manheri ]

[ October 27, 2004: Message edited by: Sunil Manheri ]
[ October 27, 2004: Message edited by: Sunil Manheri ]
 
Jeroen K.
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Shawn,

The validate method's signature is

In your code, the mapping argument is of type Action instead of ActionMapping, effectively overloading the validate method instead of overriding it. As a consequence, it will not be called by the framework.

Hope this helps,

Cheers, Jeroen
 
Shawn Hanna
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you told me about the Action mapping parameter is correct. And the Input attribute of the Action is correct so not at least the validate() method is beging called. Horray! Thank you very much. However now i'm getting a ClassCastException error inside of my jsp(according to the Stack Trace). Here is the stack trace.



Here is my updated [BOLD]struts-config.xml[/BOLD] file with the added input attributes
I changed the input to the path[BOLD] input="/pages/addNew.jsp [/BOLD]


The following is my app structure



Here is addNew.jsp

And Here is the updated validate method for connectionDetailForm
I used the deprecated ActionErrors. add() just incase the difference in ActionMessage was the problem.
[BOLD]ConnectionDetailForm [/BOLD]



Any Ideas? I think we're getting closer thanks for all your help.
 
Shawn Hanna
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for all your help.
I found this a while ago but I wanted to close this issue for others use.
Thanks.

The solution is that the Aliaslist.jsp page needed to use message tag instead of an error tag.


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic