• 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
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

struts2 action-method-validation.xml not working?

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).

ChangeAddressAction (extends ActionSupport) implements Preparable, ModelDriven<Address>

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.

<action name="ShowAddress" class="com.ChangeAddressAction" method="show">
<result>changeAddress.jsp</result>
</action>

<action name="ChangeAddress class="com.ChangeAddressAction" method="update">
<result name="input">changeAddress.jsp</result>
<result name="success">changeAddress.jsp</result>
</action>

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?!

Thanks

 
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
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.
 
M Turner
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...





where action mapping is:



and validation file is named:

PolicyAddressChangeAction-validation.xml

Any thoughts?

Much thanks.
 
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
Just to verify:

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?
 
M Turner
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.:



any more thoughts?
 
What a stench! Central nervous system shutting down. Save yourself tiny ad!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic