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

Bizarre problem with validation in Struts 2

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I am doing some experiments with Struts2, but so far, the validation framework is letting me down.

I have an Action called HelloStruts2Action, and I created the HelloStruts2Action-validation.xml

The problem is when I submit the action with an empty field, I expect the framework to return to the input page showing the error message.
What happens is that it goes to the result page as if nothing happened. The most bizarre is that when I check my app server console, it shows the following:




Somehow Struts2 knows there is a validation error, but does not redirect to the input page, even tough I have declared the input result for the action.
Also if I declare validation="true" in the JSP, the client side validation DOES work.

Here are my files:

struts.xml


the JSP that submits the request (nameCollector.jsp):



the validator xml:




Has anyone seem something like that?


Thanks
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Nope.

What version are you using? Have you made any settings in a struts.properties file? I can't duplicated it with the code you've provided; I get returned to the form page.
 
Vitor Santos
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I am using 2.1.6 version. I have no struts.properties file, so everything is on default (I guess).

I tried using JBoss 5.0 and Tomcat 6.0 and results are the same.

Another funny thing, according to struts 2 guide at ASF page, if I remove <result name="input"> struts2 should issue the following error: "No result defined for action xxx.xxx.tutorial.HellowWorld and result input" error. I tried to play with that and no error is issued.

Prabably there is some bizarre setting in my machine that is causing this.. I will try some more.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
What jar files are you including? Are you using the convention plugin?
 
Vitor Santos
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I found a solution. I made this change:



Now my action is no longe a POJO (not a big deal). I extended ActionSupport and it started working... in my opinion it shoudn't work this way...

I wasn't using the convention plugin.

thanks for your concern on this!
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Well yeah, if you don't implement Validateable and ValidationAware validation won't work as well.
 
Vitor Santos
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I felt a bit stupid after this... ActionSupport implements Validateable and ValidationAware if I am not wrong.

Thanks!!!
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Correct--a lot of S2 functionality comes from a combination of interfaces and interceptors!
 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I have been unable to get the validation framework working even after extending from ActionSupport

Please help?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Please start a new topic for new questions.

You're providing zero information we can use to help--when you create your new topic please include something useful.
    Bookmark Topic Watch Topic
  • New Topic