[
https://issues.apache.org/struts/browse/WW-2076?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_41707
]
Han Zhang commented on WW-2076:
-------------------------------
After I submitted this issue, I thought about it again and I guessed this might
be a feature, not a bug.
This is how it's working and why I thought it was an issue. The validation
works at the action class level instead of at the action method level. When I
want to have a registration form for a new user to register, I need to have two
action classes, one (ShowRegister.java) to show the empty form without
validations, one (DoRegister.java) to take the form input with validations. I
can't combine them into one class (Register.java) and have multiple methods
like show(), register() and so on in it. If I do so, the initial empty form
also triggers the validations and shows messages like "xxx is required" which
is not appropriate.
So for every form, I need to use two action classes. One with validation, and
one without. Any way to get around this?
> validation.xml cause action not called
> --------------------------------------
>
> Key: WW-2076
> URL: https://issues.apache.org/struts/browse/WW-2076
> Project: Struts 2
> Issue Type: Bug
> Components: Actions
> Affects Versions: 2.0.8
> Environment: Windows XP, Tomcat 6.0, Java 1.6.0, Eclipse 3.3 WTP
> Reporter: Han Zhang
>
> When I want to pre-populate a form in a jsp, (like ShowCompany.jsp, with data
> from database), if I have a ShowCompany-validation.xml, then Struts 2 will
> not run the ShowCompany action at all. It jumps to the ShowCompany.jsp
> directly and complains according to the validation.xml.
> Dropping the ShowCompany-validation.xml, then the action gets called. So the
> data are pulled from the database and pre-populated into the form nicely.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.