Taha, thanks a lot for your help but I am not sure if I am doing it right.

I added this as you told me:

 @Inject
 private AjaxResponseRenderer ajaxResponseRenderer;

Object onSuccess(){
    ...
     ajaxResponseRenderer.addCallback(new JavaScriptCallback() {
@Override
public void run(JavaScriptSupport arg0) {
arg0.addScript("jQuery.colorbox.close();");
}
});
     return ShowRoutePlan.class;
    }

But now the error that I am having is:
Processing of request failed with uncaught exception: Page must be
specified before initializing for partial page render.


Regards!


On Thu, May 17, 2012 at 2:36 PM, Taha Siddiqi <tawus.tapes...@gmail.com>wrote:

> Hi
>
> You can't use JavaScriptSupport directly from environment in action phase
> but you can do this
>
> @Inject
> private AjaxResponseRenderer ajaxResponseRenderer;
>
> Object onSuccess(){
> ...
>   ajaxResponseRenderer.addCallback(new JavaScriptCallback() {
>            @Override
>            public void run(JavaScriptSupport javaScriptSupport) {
>                do_whatever_you_want_to_do_with_javaScriptSupport();
>            }
>    });
>
>
> }
>
>
> regards
> Taha
>
> On May 17, 2012, at 10:56 PM, Juan Alba wrote:
>
> > Hi,
> >
> > I am working with modals in my application, for this I have done my own
> > mixin that uses *colorbox* for the modal.
> >
> > My problem, right now is that I have a form in one of those modals that
> has
> > to redirect when is submited.
> > I have two methods in the class:
> >
> >  @Inject
> >   private JavaScriptSupport javaScriptSupport;
> >
> >    void onValidateFromAddRouteForm() throws ValidationException{
> >       all the validations...
> >    }
> >
> >    Object onSuccess(){
> >        //Adding the script to close the modal and forwarding the "parent
> > iframe".
> >     javaScriptSupport.addScript("jQuery.colorbox.close();");
> >    return ShowRoutePlan.class;
> >    }
> >
> > When I get to the succes and want to close with the modal iframe I have
> > this run time error:
> > No object of type
> > org.apache.tapestry5.services.javascript.JavaScriptSupport is available
> > from the Environment.
> >
> > I have read something about not being able to add javascriptSupport on
> > render methods or something like that, but I am not sure if this is just
> > one of those cases where I just can't use javascriptSupport.
> > If it is, how can I add the javascript function for closing the page? Or
> to
> > redirect the parent instead of the iframe.
> >
> >
> > Cheers and Thanks in advance!
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

Reply via email to