Tapestry Event Bubbling

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Tapestry Event Bubbling

mr nobody
Hi guys,

I am handling an event in a page A which was bubbling from a component B:

ComponentB.java

componentResources.triggerEvent(BULK_ACTION_SELECTED, new Object[] {
selectedAction, keys}, null);

PageA.java

 void onBulkActionSelectedFromresourceSearchResults(String context,
      long[] keys) throws IOException {

    response.sendRedirect(getPageURL(linkSource, "resource/group", keys));

  }

...

public String getPageURL(PageRenderLinkSource linkSource, String page,
      long[] context) {

    Link link = linkSource.createPageRenderLinkWithContext(page, context);
    return link.toAbsoluteURI();
  }

As you can see I am trying to redirect to another page, is there any
problem in using redirect inside of an event bubbled up for a component ,
because in my case the page is not submitting.
Reply | Threaded
Open this post in threaded view
|

Re: Tapestry Event Bubbling

Thiago H de Paula Figueiredo
On Fri, 14 Nov 2014 12:26:30 -0200, Robson Pires <[hidden email]>  
wrote:

> Hi guys,

Hi! (Bão? :))

>
> I am handling an event in a page A which was bubbling from a component B:
>
> ComponentB.java
>
> componentResources.triggerEvent(BULK_ACTION_SELECTED, new Object[] {
> selectedAction, keys}, null);
>
> PageA.java
>
>  void onBulkActionSelectedFromresourceSearchResults(String context,
>       long[] keys) throws IOException {
>
>     response.sendRedirect(getPageURL(linkSource, "resource/group",  
> keys));
>
>   }

You have absolutely no reason to redirect using Response.sendRedirect().  
Just return the Link directly and Tapestry will take care of the redirect  
for you:

   Object onBulkActionSelectedFromresourceSearchResults(String context,
        long[] keys) throws IOException {

      return getPageURL(linkSource, "resource/group", keys));

   }

More details here: http://tapestry.apache.org/page-navigation.html. It's  
more common, but equally correct, to @InjectPage the target page, set the  
values you want on it, then return it, supposing the target page class has  
an onPassivate() method.

> As you can see I am trying to redirect to another page, is there any
> problem in using redirect inside of an event bubbled up for a component ,

Absolutely not. This is 100% valid.

> because in my case the page is not submitting.

What do you mean by "submitting"? Redirecting?

Have you checked whether your event handler method has actually been  
invoked?

--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Tapestry Event Bubbling

JumpStart
To illustrate, have a look at onReturnPageInstance():

        T5.4: http://jumpstart.doublenegative.com.au/jumpstart7/examples/navigation/returntypes1
        T5.3: http://jumpstart.doublenegative.com.au/jumpstart/examples/navigation/returntypes1

HTH,

Geoff


On 15 Nov 2014, at 3:39 am, Thiago H de Paula Figueiredo <[hidden email]> wrote:

> On Fri, 14 Nov 2014 12:26:30 -0200, Robson Pires <[hidden email]> wrote:
>
>> Hi guys,
>
> Hi! (Bão? :))
>
>>
>> I am handling an event in a page A which was bubbling from a component B:
>>
>> ComponentB.java
>>
>> componentResources.triggerEvent(BULK_ACTION_SELECTED, new Object[] {
>> selectedAction, keys}, null);
>>
>> PageA.java
>>
>> void onBulkActionSelectedFromresourceSearchResults(String context,
>>      long[] keys) throws IOException {
>>
>>    response.sendRedirect(getPageURL(linkSource, "resource/group", keys));
>>
>>  }
>
> You have absolutely no reason to redirect using Response.sendRedirect(). Just return the Link directly and Tapestry will take care of the redirect for you:
>
>  Object onBulkActionSelectedFromresourceSearchResults(String context,
>       long[] keys) throws IOException {
>
>     return getPageURL(linkSource, "resource/group", keys));
>
>  }
>
> More details here: http://tapestry.apache.org/page-navigation.html. It's more common, but equally correct, to @InjectPage the target page, set the values you want on it, then return it, supposing the target page class has an onPassivate() method.
>
>> As you can see I am trying to redirect to another page, is there any
>> problem in using redirect inside of an event bubbled up for a component ,
>
> Absolutely not. This is 100% valid.
>
>> because in my case the page is not submitting.
>
> What do you mean by "submitting"? Redirecting?
>
> Have you checked whether your event handler method has actually been invoked?
>
> --
> Thiago H. de Paula Figueiredo
> Tapestry, Java and Hibernate consultant and developer
> http://machina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]