struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Rodriguez Lopez <alo...@flordeutopia.pt>
Subject Re: AJAX Validation (calls to action methods work on submit, but messages not displayed nor page redirected)
Date Mon, 08 Mar 2010 11:35:27 GMT
I'm thinking this might be related to the AJAX Theme thing... is this 
required to work with AJAX validation? Any other requeriments aside from 
including the sx:head tag?

Em 08-03-2010 11:11, Alex Rodriguez Lopez escreveu:
> Hi!
>
> I'm updating validations on my app to use AJAX. I followed this:
>
> http://struts.apache.org/2.0.14/docs/ajax-validation.html
>
> Using dojo and <sx:submit validate=true/> tag, on a tipical User form page.
>
> The problem: When I click the submit button on the form, on the client
> side nothing happens, not a message displayed, not a page reload or
> request. On the server side, interceptors are called as they should,
> JSONInterceptor is called, and if there where no errors, the correct
> action and method (UserAction.save()) is called, so the data gets really
> saved, when I manually go back to the listing of the users, the user
> name got changed accordingly to the form. The only thing is that it
> appears like nothing happened when pressing the submit button.
>
> Validation worked OK before trying to implement AJAX validation. Using
> Struts 2.1.8, already have on /lib the struts2-dojo-plugin and
> <sx:head/> on my jsps.
>
> Any help on this? Thanks in advance!
>
> Alex
>
> Code:
>
> ### edit.jsp ###
>
> <s:form action="save" namespace="/user" method="POST">
> <s:token/>
> <s:hidden name="user.userID" />
> <s:textfield name="user.name" size="35" >
> <s:param name="label">
> <s:text name="label.name" />
> </s:param>
> </s:textfield>
> <s:textfield name="user.email" size="35" >
> <s:param name="label">
> <s:text name="label.email" />
> </s:param>
> </s:textfield>
> <s:textarea name="user.address" cols="32" >
> <s:param name="label">
> <s:text name="label.address" />
> </s:param>
> </s:textarea>
>
> <sx:submit validate="true" type="button" />
> </s:form>
>
> ### user-mappings.xml ###
>
> <package name="user"
> namespace="/user"
> extends="default">
>
> <action name="*" method="{1}" class="package.action.user.UserAction">
> <result type="redirect">list.action</result>
> <result name="list">/WEB-INF/content/user/list.jsp</result>
> <result name="input">/WEB-INF/content/user/edit.jsp</result>
> </action>
>
> </package>
>
> ### UserAction.java ###
>
> public String save() throws Exception {
> ServiceUser.getInstance().save(getUser());
> return SUCCESS;
> }
>
> // getter and setter for user and other stuff
>
> ### UserAction-save-validation.xml ###
>
> <validators>
> <field name="user.name">
> <field-validator type="requiredstring">
> <message>
> ${getText("error.required", {getText("label.name")})}
> </message>
> </field-validator>
> </field>
> <field name="user.email">
> <field-validator type="requiredstring">
> <message>
> ${getText("error.required", {getText("label.email")})}
> </message>
> </field-validator>
> <field-validator type="email">
> <message>${getText("error.format.email")}</message>
> </field-validator>
> </field>
> </validators>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message