• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Struts2 Validation Framework mystery

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Struts2 is new to me, and I don't know all the ins and outs -- I am hoping someone reads this and has a useful pointer for debugging this issue, as I've banged my head on it for several days with no progress.

I'm using Struts version 2.3.16.3.

I have a problem wherein the validation-framework fails to call my custom validator: "storename".

Here's what we know:
  • The Validator Works on another page in the application. This other page successfully uses the validator in exactly the same manner as my new page. In both pages the validator is referenced in a validation-framework xml file as follows (these files differ only in the name of the field to be validated)



  • The Validator Framework XML is being loaded. Notice that the sample above has two field-validators on the storeName field. The first one, "requiredstring" is called in all cases (as are most of the other field validators on the page, the single exception being "storename").
  • It's not an accessor problem. Notice again that the example has two field-validators on the storeName field, and the first one is always called.


  • Other Clues:
  • Only client-side validators are working. I don't know if this is much of a clue, but: My validator requires the database, therefore is a server-side validator. All the other validators can be checked client-side, and they do seem to be checked without hitting the server at all (as far as I can tell).
  • This page has lots of javascript, perhaps something that interferes with the invocation of server-side validation.


  • Questions:
  • Is there something special I need to do to support server-side validation? Disable client-side validation perhaps? I've found no discussion along these lines.
  • Are there any known problems with javascript interfering with the functionality of the validation framework?


  • Many thanks if you've read this far
     
    Jeff Beardsley
    Greenhorn
    Posts: 3
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Ok, I solved this one with a bit more experimentation:

    Important Note:
    Using the <submit action="ActionToTake"> will not invoke server-side validation framework code. This only works with the method form of the element: <submit method="methodToCall">. I was expecting the two to be interchangeable, because the same method would get called in either case, however, no.
     
    Bartender
    Posts: 9626
    16
    Mac OS X Linux Windows
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks for checking back in. This probably has something to do with Struts following the JavaBeans Specification where method and property names are assumed to start with lower case variables.
     
    Jeff Beardsley
    Greenhorn
    Posts: 3
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Joe Ess wrote:Thanks for checking back in. This probably has something to do with Struts following the JavaBeans Specification where method and property names are assumed to start with lower case variables.



    In the case of Actions, however ... the action is neither a method, nor a property, but rather an XML configuration element. This element itself uses the usual JavaBeans convention as found in it's attribute: method="methodToCall". The naming scheme for the action itself however, starts with uppercase, as in <action name="ActionToTake" class="com.example.MysteriousAction" method="methodToCall">
     
    Don't get me started about those stupid light bulbs.
    reply
      Bookmark Topic Watch Topic
    • New Topic