• 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

Struts Validation

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have a web app that uses STRUTS(1.1). For some reason when I changed the scope in the action tag from request to session my validation stopped working.
It looks like it's ignored.

I expect validation to pass with URL: www.site.com/ShowFile.do?lang=EN&doc=4&number=148&fileName=fileName.doc
And fail with URL: www.site.com/ShowFile.do?lang=EN
But it does not fail...

Any ideas?


Here is my struts-config.xml:


And validation.xml:

 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd suggest that in your form bean definition you set an initial value of blank to all the properties. Otherwise, if the form bean is in session scope, it retains the values last entered and therefore will pass validation even when no new value is entered.
 
Ludmila Snova
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for response. Unfortunately, it did not help. The initial values have been assigned to blanks.And, it looks like the validation is not triggered at all. It goes further to the action class, instead of going to the error page.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How are you setting the form values to blanks?
 
Ludmila Snova
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I use initial.


Then, in the action class, I print them out, and they came out blank.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you restart the server and use the example failure URL from your first message does it still "skip validation"?
 
Ludmila Snova
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. After restart it still skips validation. Is that possible that I am missing some additional parameters for a session scope?
 
Ludmila Snova
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've done some additional testing. And notice, that validation is not triggered then I have attribute="docForm" in the action tag:



When I've removed that attribute, validation is executed properly. But I need it, in order to retrieve bean from a session in the code... Is there any other way to identify form bean?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The form bean is named by the "name" attribute. If I remember correctly the "attribute" attribute is for when the form bean is named something other than the "name" attribute--I've never actually seen anybody use this.

Can you explain a bit more what you're trying to accomplish? I'm just not sure it's necessary to use "attribute".
 
Ludmila Snova
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I retrieved the bean from the session I used the attribute name. I've changed it to form name and everything works perfectly now.

Thanks a lot for your help!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic