• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

validate method is not being called

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
author
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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"
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.


 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic