Hi all,
I am trying out the Ajax Form validations in S2. I see the validations
example working perfectly fine in Showcase demo, but I can't get it to work
on my machine.
Here is what I did:
1) Created a maven project using the provided archetype.
2) Edited the struts.xml file to add my action:
<struts>
....
<package name="twms" extends="struts-default">
<action name="show" class="validations.TryValidationAction"
method="show">
<result>index.jsp</result>
<result name="input">index.jsp</result>
</action>
</package>
</struts>
3) Created src/main/java/validations/TryValidationAction.java as:
package validations;
import com.opensymphony.xwork2.ActionSupport;
public class TryValidationAction extends ActionSupport {
public String show() {
System.out.println("Show: Name = " + name + ", age = " + age);
return SUCCESS;
}
private String name;
private int age;
// .. getters and setters for the two properties
}
4) Created a
src/main/resources/validations/TryValidationAction-show-validations.xml file
as:
<validators>
<field name="name">
<field-validator type="requiredstring">
<param name="trim">true</param>
<message>Name cannot be empty</message>
</field-validator>
</field>
</validators>
5) Created src/main/webapp/twms/index.jsp as:
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>Testing Validations</title>
<s:head theme="xhtml"/>
</head>
<body>
<s:form action="show.action" theme="xhtml">
<s:textfield label="Name" name="name"/>
<s:textfield label="Age" name="age"/>
<s:submit value="Submit"/>
</s:form>
</body>
</html>
6) Configured decorators.xml to exclude my action.
With this set up in place, I was able to load the form, and see the
validations working when it is submitted. But when I change the theme to
Ajax (in the head and the form), I get plenty of Dojo errors in FireBug, I
don't get any validation errors and I am not able to submit the form.
I am using version 2.0.3 of struts, as was set up by the archetype. Can
someone help me get this working?
Thanks,
Binil
PS: I can send my simple project setup, if anyone is interested.
--
View this message in context:
http://www.nabble.com/Getting-the-AJAX-Form-Validations-to-work-tf3390223.html#a9436888
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]