Back Forum Reply New

No Ajax redirect prefix: ajax-redirect

Has anyone experienced following error with XT.doAjaxSubmit(.. ..) ?
I am submitting a signin form with doAjaxSubmit method.
When I click on 'SignIn' button, request goes to the SignInController and then to the SignInHandler.
SignInHandler:handler method returns null response.

Please advise me, if I am something wrong. Code:
2007-07-11 23:40:53,396 ERROR [org.springmodules.xt.ajax.AjaxInterceptor] - lt;No Ajax redirect prefix: ajax-redirect: found for view: signingt;
org.springmodules.xt.ajax.support.IllegalViewException: No Ajax redirect prefix: ajax-redirect: found for view: signin
at org.springmodules.xt.ajax.AjaxInterceptor.postHandle(AjaxInterceptor.java:248)
at org..web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:863)
at org..web.servlet.DispatcherServlet.doService(DispatcherServlet.java:792)
at org..web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:461)
at org..web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:426)
at javax.servlet.from.fromServlet.service(fromServlet.java:709)
Thank you,
NTR

mand.SignInCommandlt;/valuegt;lt;/propertygt;   lt;property name=quot;validatorquot;gt;lt;ref bean=quot;signInValidatorquot;/gt;lt;/propertygt;   lt;property name=quot;formViewquot;gt;lt;valuegt;signinlt;/valuegt;lt;/propertygt;   lt;property name=quot;successViewquot;gt;lt;valuegt;ajax-redirect:/testlt;/valuegt;lt;/propertygt;
lt;property name=quot;authenticationManagerquot;gt;
lt;ref bean=quot;authenticationManagerquot;/gt;
lt;/propertygt;       lt;/beangt;   lt;bean id=quot;signInValidatorquot; class=quot;org.springmodules.validation.valang.ValangValidatorquot;gt;   lt;property name=quot;valangquot;gt;   lt;valuegt;   lt;![CDATA[   {userId : ? is not blank : 'User ID must be specified' : 'errors.required'}   {password: ? is not blank : 'Password must be specified' : 'errors.required'}   ]]gt;   lt;/valuegt;   lt;/propertygt;   lt;/beangt;  lt;bean id=quot;signInHandlerquot; class=quot;com.controller.signin.handler.SignInHandlerquot;gt;   lt;/beangt;   lt;bean id=quot;ajaxInterceptorquot; class=quot;org.springmodules.xt.ajax.AjaxInterceptorquot;gt;   lt;property name=quot;handlerMappingsquot;gt;   lt;propsgt;       lt;prop key=quot;/signin.doquot;gt;signInHandlerlt;/propgt;   lt;/propsgt;   lt;/propertygt;   lt;/beangt;
And Here is my Controller:

Code:
protected ModelAndView onSubmit(Object command, BindException errors) throws Exception
{
System.out.println(quot;############ $$ Inside SignInController ###################quot;);

SignInCommand signInCommand = (SignInCommand)command;

System.out.println(quot;---gt; User Id:quot;+signInCommand.getUserId());
System.out.println(quot;---gt; Password:quot;+signInCommand.getPassword());

return new XTModelAndView(this.getSuccessView(), errors, errors.getModel());

}
Here is my Handler:

Code:
public AjaxResponse authenticateUser(AjaxSubmitEvent event)
{
System.out.println(quot;######### SignInHandler--gt;authenticateUser() ###############quot;);
SignInCommand command = (SignInCommand)event.getCommandObject();

System.out.println(quot;User Id:quot;+command.getUserId());
System.out.println(quotassword:quot;+command.getPassword());return null;
}
Thanks in advance.
NTR

mand.SignInCommandlt;/valuegt;lt;/propertygt;   lt;property name=quot;validatorquot;gt;lt;ref bean=quot;signInValidatorquot;/gt;lt;/propertygt;   lt;property name=quot;formViewquot;gt;lt;valuegt;signinlt;/valuegt;lt;/propertygt;   lt;property name=quot;successViewquot;gt;lt;valuegt;ajax-redirect:/testlt;/valuegt;lt;/propertygt;
lt;property name=quot;authenticationManagerquot;gt;
lt;ref bean=quot;authenticationManagerquot;/gt;
lt;/propertygt;       lt;/beangt;The success view is: test.

But the exception says: No Ajax redirect prefix: ajax-redirect: found for view: signin

So the question is: why does it get signin as success view name, instead of test?

Please review your code and let us know.

Cheers,

Sergio B.

quot;/gt;
lt;span id=quot;lt;cut value=quot;${status.expression}quot;/gt;_errorquot; class=quot;errorquot;gt;lt;cut value=quot;${status.errorMessage}quot;/gt;lt;/spangt;
lt;/spring:bindgt;
lt;/labelgt;lt;brgt;lt;brgt;
lt;labelgt;
Password:
lt;spring:bind path=quot;signInCommand.passwordquot;gt;
lt;input type=quot;passwordquot; name=quot;lt;cut value=quot;${status.expression}quot;/gt;quot; value=quot;lt;cut value=quot;${status.value}quot;/gt;quot; size=quot;30quot; class=quot;required validate-passwordquot; title=quot;Enter a password greater than 6 charactersquot;/gt;
lt;span id=quot;lt;cut value=quot;${status.expression}quot;/gt;_errorquot; class=quot;errorquot;gt;lt;cut value=quot;${status.errorMessage}quot;/gt;lt;/spangt;
lt;/spring:bindgt;
lt;/labelgt;
lt;/fieldsetgt;
lt;brgt;
lt;input type=quot;buttonquot; value=quot;SignMeIn quot; onclick=quot;XT.doAjaxSubmit('authenticateUser', this);quot;/gt;
lt;/formgt;
lt;/bodygt;
lt;/htmlgt;
Thank you.
NTR

Forgot to mention. I'm using springmodules 0.8

This error really driving me nuts.
Just loaded the today's nightly build and tryed. But the problem still exists.


Originally Posted by NTRThis error really driving me nuts.
Just loaded the today's nightly build and tryed. But the problem still exists.

I think it's not related to XT Ajax, but to the way your code works.

I took a look at your flow summary and your snippets and there seems to be just one thing that is wrong: your form validation will not work as you could expect, that is, errors will not be displayed in your page.
Moreover, by looking at your code it seems that you should actually get that kind of exception when the form doesn't pass validation: this is because when the validation fails, the next view actually becomes signin.

So, are you sure that your validation succeeds?

Moreover, if you're still in troubles, please attach here your code as a zip file, in a way that I can easily run it: I'll debug it ASAP.

Let me know.
Cheers,

Sergio B.

Sergio,
You are absolutely correct. My validations are not working with the AJAX-call (but working with non ajax submit).
Could you please quickly point out what is wrong with my validations?
In the meantime, I will send you a zip file for your verification.
Thank you.
NTR


Originally Posted by NTRCould you please quickly point out what is wrong with my validations?

While server-side validation doesn't change if using XT Ajax features, handling the client behavior (error displaying, page redirecting ...) is different, because you have to write an Ajax handler for sending the response to the client.
You have two ways ...
You can easily use the already shipped ready-to-use DefaultValidationHandler: d...jax-tutorial-3
Or you can write a brand new Ajax handler to fit your needs: this is not difficult, just remember that if you want to display something in your web page, you have to return a non-empty AjaxResponse; if you return an empty (or null) AjaxResponse, you will be redirected to the next view (see d...le/#ajax-flow).

Let us know if you need other info.

Cheers,

Sergio B.

Thank you for your advise. I have changed my validator to DefaultValidationHandler things are working great. Error messages are properly displayed and the flow is redirected to ajax-redirect:/test.do.

But I am getting this exception: lt;Neither BindingResult nor plain target object for bean name 'signInCommand' available as request attributegt;
Code:

2007-07-14 16:05:19,873 ERROR [org..web.servlet.tags.BindTag] - lt;Neither BindingResult nor plain target object for bean name 'signInCommand' available as request attributegt;
javax.servlet.jsp.JspTagException: Neither BindingResult nor plain target object for bean name 'signInCommand' available as request attribute
at org..web.servlet.tags.BindTag.doStartTagInternal(BindTag.java:119)
at org..web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:77)
at org.apache.jsp.view.signin_jsp._jspService(signin_jsp.java:91)
at org.apache.jasper.runtime.fromJspBase.service(fromJspBase.java:97)
at javax.servlet.from.fromServlet.service(fromServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.from.fromServlet.service(fromServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:574)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:499)
at org..web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:134)
at org..web.servlet.view.AbstractView.render(AbstractView.java:243)
Do I need to put the 'signInCommand' object in request or session (though I don't use this object in my redirected view). Please advise me how to get rid of this exception.

Thank you,
NTR.
¥
Back Forum Reply New