I have an action for updating an address object: ChangeAddressAction which has 2 methods: show() and update(). This action implements prepare() and getModel(). I have the following validation file -> ChangeAddressAction-update-validation.xml in my action package (along with other validations).
prepare() - sets up an action attribute
getModel() - returns the address object
show() - populates the action's address object - renders the jsp to the user
update() - expects a VALID populated address object to send to the service
I call an action mapping to render the changeAddress.jsp which calls the ChangeAddressAction show() method. The JSP renders with all of the pre-populated address information. However when I submit (to a different action mapping calling the same action with the update() method), the validations on the action are not performed.
From the documentation that I've seen so far I thought it would be enough to name the validation file the same as the ChangeAddressAction-update-validation.xml for validations to be triggered, but they aren't triggered. I have several other validation files that do not have aliases which trigger as expected. What am I doing wrong?!
Please UseCodeTags when posting code or configuration. Unformatted code and configuration is very difficult to read. You can edit your post to include them by using the button.
Joined: Dec 16, 2009
I have removed the alias method from my action and am calling the execute() method directly but still my validation is still not firing. The validation field names seem to match the field names in the JSP...
The action extends ActionSupport?
You're running the default interceptor stack?
The validation file is in the same directory as the action, and is being deployed?
Does it work for a "simple" action property (like "fname" or something, to see if it's an OGNL navigation issue)?
If the action populates the form field it's being displayed on the form?
With logging set to DEBUG is there anything regarding validation in the logs?
Joined: Dec 16, 2009
Thanks very much for your prompt reply
David Newton wrote:Just to verify:
The action extends ActionSupport? YES
You're running the default interceptor stack? YES
The validation file is in the same directory as the action, and is being deployed? YES
Does it work for a "simple" action property (like "fname" or something, to see if it's an OGNL navigation issue)? - since the flow falls through to the action, a breakpoint in the execute() shows that the object IS being populated - there are no OGNL warnings in the log
If the action populates the form field it's being displayed on the form? I'm using 2 actions now: 1) populate the address object and show the form page and 2) populates a service object (which has the address object nested in it) using ModelDriven and sends the edits to the service - I know I shouldn't have to use 2 actions in struts2 but I haven't gotten things to work otherwise...
With logging set to DEBUG is there anything regarding validation in the logs? - there are no validation OR converter errors in the log
Actually, the 2 actions bother me because I'm sure there's something there. The "set up" action has the "newBillingAddress" in it as an action attribute while the "update" action has "newBillingAddress" nested as an attribute of a service object. However, I did try putting a "newBillingAddress" object in the "update" action and setting it into the service object but it didn't change anything.
I ALSO tried putting the nested property field name in my validation.xml, in case that was the problem e.g.: