You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Gerald Schöffel <ta...@online.de> on 2006/02/06 18:59:11 UTC

How to find the right service ...

Hi, it is me again :)

Again with some 'service trouble' ...

An IExternalPage is called from the browser.

in pageValidate (defined in MyBasePage only, all other pages are extending this page), I notice, that a login is required an therefor I redirect to the Login page:

throw new PageRedirectException(getLoginPage()) ;

-> now the pageValidate of Login.page is called and

logger.info("service:"+getRequestCycle().getService().getName()) ;

writes 'external' into the log (or an exception is thrown stating Login.page did not implement IExternalPage :) ).

In my understanding this should be 'page' ? Or is PageRedirectException(login) internally forwarding to the new page without refreshing the requestCycle() (also tried event.getRequestCycle(), getPage().getRequestCycle()).

I need the actual service the login-page is rendered with because I want to build a url using the services getLink() method.

So, does anyone know how to distinguish the services the right way ?

Would be great to get some feedback, I am browsing the docs / hacking my code for hours now to find a better solution to get the actual service. But till now I did not found one :(

Thank you in advance !

Bye, 
Gerald

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: How to find the right service ...

Posted by Gerald Schöffel <ta...@online.de>.
Hi Ivano,

thank you for your reply.

I am using Tapestry 4.0.

I need the absolute url, because I want to forward (based on security 
constraints of the page (or one of the containing components) currently 
rendered) to the right scheme.

Because I noticed, that getRequestCycle() is not the right place to find 
the service needed for the current page in, I am currently checking with 
'if (getPage() instanceof IExternalPage) ...' in the pageValidate method.

But I think I am at the wrong place to do it (pageValidate), because 
after getting things to work, the parameters of the external page are 
gone :(

It is sooooooo frustrating ... this could be the perfect security 
'framework' for me. Everything was working fine (transparent forwarding 
to https/http/login page whenevever the app needs it) until the 
different services where involved :(

Maybe someone could give me a hint, where to intercept the response 
rendering to forward to a different scheme is the best place for.

Here is a commented excerpt from the logfile to make things clear ...

External page is called from the browser (needs login):

validate begin --------------------------------
validate:page   :MyExternalPage
validate:service:external
validate:scheme :http
login needed !
external callback stored
redirect to login page (throw new PageRedirectException(getLoginPage()))

login page is marked to need https ....

validate begin --------------------------------
validate:page   :secure/Login
validate:service:external   (!!!!) I am still in the same requestCylce ?
validate:scheme :http
wrong scheme, switching to https
normal page, building url   (instanceof IExternalPage ...)
webRequest.forward(https-url)
validate end --------------------------------

OK, now the scheme is https:

validate begin --------------------------------
validate:page   :secure/Login
validate:service:page
validate:scheme :https
validate end --------------------------------

form is submitted:

validate begin --------------------------------
validate:page   :secure/Login
validate:service:direct
validate:scheme :https
validate end --------------------------------

listener is called:

doLogin starts <- listener bound to submit

login was OK, activating Callback (the EXTERNAL one stored above)
getCallback().performCallback(getRequestCycle())

validate begin --------------------------------
validate:page   :MyExternalPage
validate:service:direct		(!!!!!)  :(
validate:scheme :https
scheme wrong, switching to http
external page, building url	(instanceof IExternalPage ...)

build url with:
ExternalServiceParameter eparams = new 
ExternalServiceParameter(getPage().getPageName(), 
getRequestCycle().getListenerParameters()) ;
link = getExternalService().getLink(false, eparams).getAbsoluteURL() ;

webRequest.forward(http-url) (**1**)
validate end --------------------------------
doLogin ends

Then a NullPointerException is thrown, because the url I have forwarded 
to in (**1**) does not contain the parameters from the original external 
service, so activateExternalPage is throwing this exception :(

Any ideas ?

Thanks again !

Gerald

Ivano wrote:
> Why do you need to build the url? What Tapestry version are you using?
> 
> Ivano Pagano.
> 
> Gerald Schöffel wrote:
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: How to find the right service ...

Posted by Ivano <i....@mclink.it>.
Why do you need to build the url? What Tapestry version are you using?

Ivano Pagano.

Gerald Schöffel wrote:

>Hi, it is me again :)
>
>Again with some 'service trouble' ...
>
>An IExternalPage is called from the browser.
>
>in pageValidate (defined in MyBasePage only, all other pages are extending this page), I notice, that a login is required an therefor I redirect to the Login page:
>
>throw new PageRedirectException(getLoginPage()) ;
>
>-> now the pageValidate of Login.page is called and
>
>logger.info("service:"+getRequestCycle().getService().getName()) ;
>
>writes 'external' into the log (or an exception is thrown stating Login.page did not implement IExternalPage :) ).
>
>In my understanding this should be 'page' ? Or is PageRedirectException(login) internally forwarding to the new page without refreshing the requestCycle() (also tried event.getRequestCycle(), getPage().getRequestCycle()).
>
>I need the actual service the login-page is rendered with because I want to build a url using the services getLink() method.
>
>  
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org