Anyway I want to be more detailed about my use case:
I have a complex form with a lot of fields with cross validation rules (some fields validation depends from other fields value). It's very common that users make a mistake filling out the form so I would avoid to have complete page render each time the user try to submit data. Only If there are no error on page I will go to the next page in the application flow.
So AjaxFormSubmitBehavior is perfect for this use case. In onSubmit(target) method I check for any validation error, if any exists I will notify user about that with a _javascript_ alert / target.addJavascript("alert('..')") /.
If validation pass the form onSubmit will execute storing submitted data and proceeding to to next page / setResponsePage / .
I was a bit surprised to see that setResponsePage was not working in conjunction an AjaxFormSubmitBehavior request.
I think Eelco proposal to make AjaxRequestTarget translating page redirect to window.location is good idea. In this way setResponsePage semantic will be more uniform with both plain and ajax submit.
Thanks.
- Paolo
But in my case, I'm using AjaxFormSubmitBehavior to validate and saving user data .
On 7/21/06, Eelco Hillenius <
[EMAIL PROTECTED]> wrote:
I don't know whether it is that uncommon. Now that I think of it, I
can think of a few use cases, certainly when you want to handle
exceptional situations.
But Paolo, please tell us more about your use case. Are you sure you
want to redirect to a page there?
Eelco
On 7/21/06, Igor Vaynberg < [EMAIL PROTECTED]> wrote:
> sure, we could add a utility method. but think about what you are doing -
> you want to redirect a browser from an /ajax/ request. this is not a common
> usecase i dont think. the whole point of ajax is to work on the same page
> and avoid the redirects :)
>
> -Igor
>
>
>
> On 7/21/06, Eelco Hillenius < [EMAIL PROTECTED]> wrote:
> > Could we make AjaxRequestTarget a bit smarter so that it would have a
> > setResponsePage method that translates to window.location= instead of
> > the redirect we do for normal requests?
> >
> > Eelco
> >
> >
> > On 7/21/06, Igor Vaynberg < [EMAIL PROTECTED]> wrote:
> > >
> target.addJavascript ("window.location='"+RequstCycle.get().urlFor(null,
> > > MyPage.class)+"';");
> > >
> > > you can only redirect to a class not an instance so you will have to
> pass
> > > params using PageParameters.
> > >
> > > maybe we should add urlFor(Page) to request cycle
> > >
> > > -Igor
> > >
> > >
> > >
> > > On 7/21/06, Paolo Di Tommaso < [EMAIL PROTECTED] > wrote:
> > > >
> > >
> > > I'm getting a bit confused how to redirect to a new page after a form
> > > submission using AjaxFormSubmitBehavior.
> > >
> > > I use the onSubmit method of AjaxFormSubmitBehavior component to notify
> user
> > > for special message, for example:
> > >
> > > buttonSave.add( new AjaxFormSubmitBehavior ( form, "onclick" ) {
> > > protected void onSubmit(AjaxRequestTarget target) {
> > > if( !getFeedbackMessages().isEmpty() ) {
> > > target.addJavascript( "alert('Validation failed')" );
> > > }
> > > }
> > > });
> > >
> > >
> > > and the form onSubmit to save data and redirect to the next page:
> > >
> > > form = new Form("form1") {
> > >
> > > void onSubmit() {
> > >
> > > if( findSubmittingButton() == buttonSave ) {
> > >
> > > dao.save( object );
> > > setResponsePage( NextPage.class );
> > > }
> > > }
> > > };
> > >
> > > The problem is that in this way I will get the response page as response
> > > content of the Ajax call!
> > >
> > > How to redirect to another page using AjaxFormSubmitBehavior?
> > >
> > >
> > > Thanks for helping.
> > >
> > >
> > > - Paolo
> > >
> > >
> > >
> -------------------------------------------------------------------------
> > > Take Surveys. Earn Cash. Influence the Future of IT
> > > Join SourceForge.net's Techsay panel and you'll get the chance to share
> your
> > > opinions on IT & business topics through brief surveys -- and earn cash
> > >
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> > >
> > > _______________________________________________
> > > Wicket-user mailing list
> > > Wicket-user@lists.sourceforge.net
> > >
> https://lists.sourceforge.net/lists/listinfo/wicket-user
> > >
> > >
> > >
> > >
> > >
> -------------------------------------------------------------------------
> > > Take Surveys. Earn Cash. Influence the Future of IT
> > > Join SourceForge.net's Techsay panel and you'll get the chance to share
> your
> > > opinions on IT & business topics through brief surveys -- and earn cash
> > >
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> > >
> > > _______________________________________________
> > > Wicket-user mailing list
> > > Wicket-user@lists.sourceforge.net
> > >
> https://lists.sourceforge.net/lists/listinfo/wicket-user
> > >
> > >
> > >
> >
> >
> -------------------------------------------------------------------------
> > Take Surveys. Earn Cash. Influence the Future of IT
> > Join SourceForge.net's Techsay panel and you'll get the chance to share
> your
> > opinions on IT & business topics through brief surveys -- and earn cash
> >
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> > _______________________________________________
> > Wicket-user mailing list
> > Wicket-user@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/wicket-user
> >
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys -- and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
>
>
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user