Author: musachy Date: Sat Apr 28 10:02:37 2007 New Revision: 533391 URL: http://svn.apache.org/viewvc?view=rev&rev=533391 Log: WW-1897 Create JSONValidationInterceptor * Update showcase to use new json validation interceptor
Modified: struts/struts2/trunk/apps/showcase/src/main/resources/struts-ajax.xml struts/struts2/trunk/apps/showcase/src/main/resources/struts-validation.xml struts/struts2/trunk/apps/showcase/src/main/webapp/validation/index.jsp struts/struts2/trunk/apps/showcase/src/main/webapp/validation/quiz-ajax.jsp Modified: struts/struts2/trunk/apps/showcase/src/main/resources/struts-ajax.xml URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/resources/struts-ajax.xml?view=diff&rev=533391&r1=533390&r2=533391 ============================================================================== --- struts/struts2/trunk/apps/showcase/src/main/resources/struts-ajax.xml (original) +++ struts/struts2/trunk/apps/showcase/src/main/resources/struts-ajax.xml Sat Apr 28 10:02:37 2007 @@ -74,5 +74,9 @@ <action name="AutocompleterExample" class="org.apache.struts2.showcase.ajax.AutocompleterExampleAction"> <result type="freemarker">/ajax/options.ftl</result> </action> + <action name="quizAjax" class="org.apache.struts2.showcase.validation.QuizAction"> + <interceptor-ref name="jsonValidationWorkflowStack"/> + <result>/validation/quiz-success.jsp</result> + </action> </package> </struts> Modified: struts/struts2/trunk/apps/showcase/src/main/resources/struts-validation.xml URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/resources/struts-validation.xml?view=diff&rev=533391&r1=533390&r2=533391 ============================================================================== --- struts/struts2/trunk/apps/showcase/src/main/resources/struts-validation.xml (original) +++ struts/struts2/trunk/apps/showcase/src/main/resources/struts-validation.xml Sat Apr 28 10:02:37 2007 @@ -20,6 +20,7 @@ </action> <action name="quizAjax" class="org.apache.struts2.showcase.validation.QuizAction"> + <interceptor-ref name="jsonValidationWorkflowStack"/> <result name="input">quiz-ajax.jsp</result> <result>quiz-success.jsp</result> </action> Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/validation/index.jsp URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/validation/index.jsp?view=diff&rev=533391&r1=533390&r2=533391 ============================================================================== --- struts/struts2/trunk/apps/showcase/src/main/webapp/validation/index.jsp (original) +++ struts/struts2/trunk/apps/showcase/src/main/webapp/validation/index.jsp Sat Apr 28 10:02:37 2007 @@ -30,7 +30,7 @@ <li><s:a href="%{clientSideValidationUrl}">Field Validators with client-side JavaScript</s:a></li> <li><s:a href="%{nonFieldValidatorUrl}">Non Field Validator</s:a></li> <li><s:a href="%{storeMessageAcrossRequestExample}">Store across request using MessageStoreInterceptor (Example)</s:a></li> - <li>(broken) <s:a href="%{quizAjax}">Validation (ajax)</s:a></li> + <li><s:a href="%{quizAjax}">Validation (ajax)</s:a></li> <li><s:a href="%{quizBasic}">Validation (basic)</s:a></li> <li><s:a href="%{quizClient}">Validation (client)</s:a></li> <li><s:a href="%{quizClientCss}">Validation (client using css_xhtml theme)</s:a></li> Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/validation/quiz-ajax.jsp URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/validation/quiz-ajax.jsp?view=diff&rev=533391&r1=533390&r2=533391 ============================================================================== --- struts/struts2/trunk/apps/showcase/src/main/webapp/validation/quiz-ajax.jsp (original) +++ struts/struts2/trunk/apps/showcase/src/main/webapp/validation/quiz-ajax.jsp Sat Apr 28 10:02:37 2007 @@ -1,21 +1,87 @@ <%@ taglib prefix="s" uri="/struts-tags" %> +<%@ taglib prefix="sx" uri="/struts-dojo-tags" %> <!-- START SNIPPET: ajaxValidation --> <html> <head> - <title>Validation - Basic</title> - <s:head theme="ajax"/> + <title>Validation -Ajax</title> + <sx:head debug="true" cache="true" compressed="false"/> </head> +<s:url id="url" namespace="/validation" action="quizAjax"/> + <body> -<s:form method="post" validate="true" theme="ajax"> - <s:textfield label="Name" name="name"/> - <s:textfield label="Age" name="age"/> +<h5>1.Use AJAX validation, and AJAX request (ajaxAfterValidation="true"), if validation succeeds</h5> + +<div id="response" style="border: 1px solid black"> + Response goes here +</div> + +<br /> + +<s:form method="post" theme="xhtml" namespace="/nodecorate" action="quizAjax" id="form"> + <s:textfield label="Name" name="name" /> + <s:textfield label="Age" name="age" /> + <s:textfield label="Favorite color" name="answer"/> + <sx:submit + validate="true" + ajaxAfterValidation="true" + targets="response" + showLoadingText="false"/> +</s:form> + +<sx:a + formId="form" + validate="true" + ajaxAfterValidation="true" + targets="response" + showLoadingText="false">Submit Form with a link</sx:a> +<br /><br /> + +<input type="checkbox" id="checkbox">Submit Form listening to an event on an element (check to submit) +<sx:bind + id="bind" + formId="form" + sources="checkbox" + validate="true" + events="onchange" + ajaxAfterValidation="true" + targets="response" + showLoadingText="false"/> + +<br /><br /><br /><br /> + +<h5>2.Use AJAX validation, and regular request (ajaxAfterValidation="false", default), if validation succeeds</h5> +<br /> + +<s:form method="post" theme="xhtml" namespace="/nodecorate" action="quizAjax" id="form2"> + <s:textfield label="Name" name="name" /> + <s:textfield label="Age" name="age" /> <s:textfield label="Favorite color" name="answer"/> - <s:submit/> + <sx:submit + validate="true" + ajaxAfterValidation="false" + showLoadingText="false"/> </s:form> + +<sx:a + formId="form2" + validate="true" + ajaxAfterValidation="false" + showLoadingText="false">Submit Form with a link</sx:a> +<br /><br /> + +<input type="checkbox" id="checkbox2">Submit Form listening to an event on an element (check to submit) +<sx:bind + formId="form2" + sources="checkbox2" + validate="true" + events="onchange" + ajaxAfterValidation="false" + showLoadingText="false"/> + </body> </html>