This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts 2 - client side basic validation

Peter Molina
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am playin with struts 2.1.8 + tiles and trying out client side validation and running in a strange issue with required string validation, regardless of whether or not a value is put in the text field, after clicking submit, struts always display the error message from action-validation.xml and the text field value clears out. When value is put in the text field, I would expect submit to take it the execute() of dosubmit class. For actions without validation everything works as expected. I think I am missing something very basic. Code snippets -

struts.xml -

<action name="dosubmit" class="">
<result name="success" type="tiles">successpageDef</result>
<result name="input" type="tiles">inputpageDef</result>

inputpageDef body -

s:form action="dosubmit" method="post" validate="true" >
<s:textfield name="first" key="first" label="First" size="15" />
<s:submit value="Submit"/>

dosubmit-validation.xml -

<field name="first">
<field-validator type="requiredstring">
<param name="trim">true</param>
<message>First is required</message>

Any help/pointers is appreciated.

David Newton
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags when posting code or configuration. Unformatted code and configuration is unnecessarily difficult to read.

You can edit your post by using the button.

By the way, if you use the "key" attribute, there's little reason to use the "name" and "label" attributes; the "key" attribute is meant to eliminate the need for them.

I don't see anything obviously wrong; did you check to make sure the correct JavaScript is rendering? I'd also remove the <div> tags around the for elements; I'm not sure if that's legal HTML (wrapping div tags around table rows, I mean)--not sure, and can't check at the moment.

Welcome to JavaRanch!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic