Re: Redirect onActivate - how to handle ActionLink requests?

2012-12-21 Thread lebenski
This is exactly what I was looking for!  Thank you.  Although I still notice
a strange issue.  In all cases except one the following works:

 componentEventLinkEncoder.decodePageRenderRequest(request) != null

Except on the request made by the autocomplete mixin
(http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/corelib/mixins/Autocomplete.html)
that I am using.  The path for the autocomplete request is:
/editcube.card:autocomplete but
componentEventLinkEncoder.decodePageRenderRequest(request) returns
PageRenderRequestParameters[CubeBlog].  CubeBlog is the name of my
START_PAGE_NAME as defined in AppModule.

As a result I've been using

componentEventLinkEncoder.decodeComponentEventRequest(request) == null

This works fine for everything, but I am curious if anyone could explain why
decodePageRenderRequest doesn't seem to behave as expected for the
autocomplete mixin request?



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Redirect-onActivate-how-to-handle-ActionLink-requests-tp5718883p5718916.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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



Re: Redirect onActivate - how to handle ActionLink requests?

2012-12-21 Thread Thiago H de Paula Figueiredo
On Fri, 21 Dec 2012 09:18:47 -0200, lebenski ben.titma...@hotmail.co.uk  
wrote:



This is exactly what I was looking for!  Thank you.


:D

Although I still notice a strange issue.  In all cases except one the  
following works:


 componentEventLinkEncoder.decodePageRenderRequest(request) != null

Except on the request made by the autocomplete mixin
(http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/corelib/mixins/Autocomplete.html)
that I am using.  The path for the autocomplete request is:
/editcube.card:autocomplete but
componentEventLinkEncoder.decodePageRenderRequest(request) returns
PageRenderRequestParameters[CubeBlog].


That's weird and unexpected.


CubeBlog is the name of my START_PAGE_NAME as defined in AppModule.


That may be the explanation.


As a result I've been using
componentEventLinkEncoder.decodeComponentEventRequest(request) == null

This works fine for everything,


Nice! :)

--
Thiago H. de Paula Figueiredo

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



Re: Redirect onActivate - how to handle ActionLink requests?

2012-12-20 Thread Thiago H de Paula Figueiredo
On Thu, 20 Dec 2012 14:23:11 -0200, lebenski ben.titma...@hotmail.co.uk  
wrote:


So I have a page 'ViewCube'.  This page can be accessed by anyone and  
does not allow any editing rights.  I then have a page 'EditCube' which  
extends ViewCube


I wouldn't do that. A page for viewing is very different from a page for  
editing. If there's something that is common, put it in a component and  
use it in both pages. Avoid inheritance, prefer composition. ;)



and uses some extension points to allow the user with editing
rights to modify the cube (please don't worry about what a Cube is!)


You're just make me curious about these cubes. :P


So - am I doing the redirect in the right way?  Is this inheritance
sensible?  I tried using response.sendRedirect so that I don't need a  
return value but this fails with the following:


Don't use Response.sendRedirect() either.

--
Thiago H. de Paula Figueiredo

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



Re: Redirect onActivate - how to handle ActionLink requests?

2012-12-20 Thread lebenski
Hi Thiago,

Ok but I don't believe that my problem is directly related to inheritance,
but point taken on the style preference.  Even if I have two separate pages
with components I will still need the check in the edit page with the
redirect to the view page.  In this case, how do I handle actionLink
requests hitting the onActivate() and getting null returned without hitting
the handler?




--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Redirect-onActivate-how-to-handle-ActionLink-requests-tp5718883p5718893.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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



Re: Redirect onActivate - how to handle ActionLink requests?

2012-12-20 Thread lebenski
I actually got the problem wrong, it's not the fact that the null return
prevented the handler from firing, but rather my condition to determine if
it was a page request rather than a component request was insufficient:

protected boolean isPageRequest() {
return !request.isXHR()  request.getMethod()==GET;
}

And it was ending up redirecting. 

What is the preferred way to check in an onActivate method whether the
originating request is a page request or simply a component like an
actionLink making a request?



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Redirect-onActivate-how-to-handle-ActionLink-requests-tp5718883p5718894.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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



Re: Redirect onActivate - how to handle ActionLink requests?

2012-12-20 Thread Cezary Biernacki
Hi,
Are you sure that your onActivate method is related to your problem with
event handler not being called?

It can be something quite unrelated.

For example the event handler method can be incorrectly named
(if you are using naming convention),
or with @OnEvent annotation parameters can be wrong.

Another possibility is that 'CardLightBox' itself handles the event.

Best regards,
Cezary

On Thu, Dec 20, 2012 at 5:23 PM, lebenski ben.titma...@hotmail.co.ukwrote:

 Inside a component called 'CardLightBox' in EditCube.  When this makes the
 following request:

 /editcube.cardlightbox.addcard

 The onActivate method kicks in, returning null and my request is not
 fulfilled by the event handler in the page class.



Re: Redirect onActivate - how to handle ActionLink requests?

2012-12-20 Thread Cezary Biernacki
So your onActivate method does not actually return null but redirects to
another page.
That explains why handler is not called.

I am not sure what is preferred method to detect page requests vs. event
requests in onActivate methods,
but I can imagine that it could be done by
decorating ComponentRequestHandler
and adding a request attribute with information of kind of request.

However it seems to be quite risky to disable security checks for component
requests.
Are you going to add a security check to every component request handler?


Best regards,
Cezary


On Thu, Dec 20, 2012 at 6:41 PM, lebenski ben.titma...@hotmail.co.ukwrote:

 I actually got the problem wrong, it's not the fact that the null return
 prevented the handler from firing, but rather my condition to determine if
 it was a page request rather than a component request was insufficient:

 protected boolean isPageRequest() {
 return !request.isXHR()  request.getMethod()==GET;
 }

 And it was ending up redirecting.

 What is the preferred way to check in an onActivate method whether the
 originating request is a page request or simply a component like an
 actionLink making a request?



 --
 View this message in context:
 http://tapestry.1045711.n5.nabble.com/Redirect-onActivate-how-to-handle-ActionLink-requests-tp5718883p5718894.html
 Sent from the Tapestry - User mailing list archive at Nabble.com.

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




Re: Redirect onActivate - how to handle ActionLink requests?

2012-12-20 Thread Thiago H de Paula Figueiredo
On Thu, 20 Dec 2012 16:10:05 -0200, Cezary Biernacki cezary...@gmail.com  
wrote:



I am not sure what is preferred method to detect page requests vs. event
requests in onActivate methods,
but I can imagine that it could be done by
decorating ComponentRequestHandler
and adding a request attribute with information of kind of request.


Please don't do that. Just @Inject ComponentEventLinkEncoder and use its  
createPageRenderLink() method. If it returns null, it's not a page render  
request, so it's an event one.


--
Thiago H. de Paula Figueiredo

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



Re: Redirect onActivate - how to handle ActionLink requests?

2012-12-20 Thread Cezary Biernacki
On Thu, 20 Dec 2012 16:10:05 -0200, Cezary Biernacki 
cezary...@gmail.com wrote:



I am not sure what is preferred method to detect page requests vs. event
requests in onActivate methods,
but I can imagine that it could be done by
decorating ComponentRequestHandler
and adding a request attribute with information of kind of request.


Please don't do that. Just @Inject ComponentEventLinkEncoder and use 
its createPageRenderLink() method. If it returns null, it's not a page 
render request, so it's an event one.

createPageRenderLink()?
Documentation does not suggest that it works differently during event 
requests.

Maybe you thought about decodePageRenderRequest()?

Best regards,
Cezary


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



Re: Redirect onActivate - how to handle ActionLink requests?

2012-12-20 Thread Thiago H de Paula Figueiredo
On Thu, 20 Dec 2012 20:52:08 -0200, Cezary Biernacki cezary...@gmail.com  
wrote:


On Thu, 20 Dec 2012 16:10:05 -0200, Cezary Biernacki  
cezary...@gmail.com wrote:


I am not sure what is preferred method to detect page requests vs.  
event

requests in onActivate methods,
but I can imagine that it could be done by
decorating ComponentRequestHandler
and adding a request attribute with information of kind of request.


Please don't do that. Just @Inject ComponentEventLinkEncoder and use  
its createPageRenderLink() method. If it returns null, it's not a page  
render request, so it's an event one.

createPageRenderLink()?
Documentation does not suggest that it works differently during event  
requests.

Maybe you thought about decodePageRenderRequest()?


Yep, decodePageRenderRequest().

--
Thiago H. de Paula Figueiredo

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