If you redirecting , no JavaScript will run. 

If you want colorbox to close and you stay on the same page don't redirect. If 
you want to redirect then why to close the colorbox. 

Sent from my iPhone

On May 18, 2012, at 12:09 AM, Juan Alba <juan.a...@condortech.com.ar> wrote:

> Taha, thanks Again but still can't make it work.
> 
> I have this now:
> *tml:*
> 
> <t:zone t:id="formZone" id="formZone">
> <t:form t:id="addRouteForm" t:zone="formZone">
> <t:errors/>
> ${message:name}
> <t:textfield t:id="routeName"/>
> <t:submit/>
> </t:form>
> </t:zone>
> 
> 
> in the *class*
> 
> Object onSuccess(){
> 
>   if (request.isXHR()) {
>     ajaxResponseRenderer.addCallback(new JavaScriptCallback() {
>         @Override
>          public void run(JavaScriptSupport arg0) {
>         arg0.addScript("alert('a');");
>          }
>     });
>   }
> return pageRenderLinkSource.createPageRenderLink(ShowRoutePlan.class);
> }
> 
> 
> But theres is no alert. The pageRenderLinkSource is redirecting fine, I
> have no problems there, but is never getting to the "alert ('a')".
> Debbuging I found out that it gets in the if, but is never reaching to the
> arg0.addScript.
> 
> Any idea?
> 
> Regards and thanks in advance for your time and help!
> 
> 
> On Thu, May 17, 2012 at 3:12 PM, Taha Siddiqi <tawus.tapes...@gmail.com>wrote:
> 
>> It has to be an ajax request for ajaxResponseRenderer to work.
>> 
>> Also, for an ajax request if you want to redirect return an instance of
>> Link from the event handler.
>> 
>> return pageRenderLinkSource.createPageRenderLink(ShowRoutePlan.class);
>> 
>> regards
>> Taha
>> 
>> On May 17, 2012, at 11:25 PM, Juan Alba wrote:
>> 
>>> 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
>>>> 
>>>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>> For additional commands, e-mail: users-h...@tapestry.apache.org
>> 
>> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to