GeeCON Prague 2014*
The moose likes Struts and the fly likes validate method is not being called Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "validate method is not being called" Watch "validate method is not being called" New topic
Author

validate method is not being called

Shawn Hanna
Greenhorn

Joined: Oct 27, 2004
Posts: 5
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

Joined: Jan 11, 2001
Posts: 114
You form needs to extend org.apache.struts.validator.ValidatorForm.


Matt<br /> <br />Author: <a href="http://springlive.com" target="_blank" rel="nofollow">Spring Live</a> and <a href="http://www.apress.com/book/bookDisplay.html?bID=256" target="_blank" rel="nofollow">Pro JSP</a><br />Weblogs: <a href="http://raibledesigns.com" target="_blank" rel="nofollow">Raible Designs</a> <a href="http://jroller.com/page/raible" target="_blank" rel="nofollow">Spring Live Blog</a>
Shawn Hanna
Greenhorn

Joined: Oct 27, 2004
Posts: 5
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

Joined: Jul 04, 2003
Posts: 1312
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"


SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
Sunil Manheri
Ranch Hand

Joined: Jul 07, 2004
Posts: 32
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 ]

TechMindViews - Technical Notes
Jeroen K.
Greenhorn

Joined: Aug 03, 2004
Posts: 2
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

Joined: Oct 27, 2004
Posts: 5
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

Joined: Oct 27, 2004
Posts: 5
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.


 
 
subject: validate method is not being called