Where to check that the user is logged in when rendering a page

2009-01-16 Thread Jonathan O'Connor

Hi,
I have been reading the documentation, and I haven't seen what I need to 
find out: How can a page finding that the user is not logged in, it 
should jump to a login page, and optionally jump back to the requested page?


I already know how to check the session to see if a) there is a session, 
and b) that a user logged in correctly. What I need to know is:
1. What method/annotation do I need to write in my page class before the 
page renders
2. Presumably, I want to return a Page or a URL from this method, to 
redirect to the login page.
3. Should the login page take a hidden field to say which page it wants 
to go to next?


BTW, I would love to see, in one place, a list of all the methods added 
by the classloader, how it was triggered. The list I know about are:
1. Component Rendering Methods: setupRender, beginRender, 
beforeRenderTemplate, beforeRenderBody, afterRenderBody, 
afterRenderTemplate, afterRender, cleanupRender.

2. Page Lifecycle methods: pageLoaded, pageAttached, pageDetached
3. Page activation events: onActivate, onPassivate
4. Action events: onActionFromBlah, onSubmit
5. Form events: prepareForRender, prepare, prepareForSubmit, onValidate, 
onSuccess, onFailure, onSubmit

6. getters and setters of @Property annotated private attributes.

No doubt I've missed a few more.
Thanks,
Jonathan

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



Re: Where to check that the user is logged in when rendering a page

2009-01-16 Thread Jonathan O'Connor

Thiago,
thanks very much. That's basically what I did, and it works, but I don't 
like:

a) not having a passivate method (I have no need of one yet) and
b) I feel (due to the examples in the documentation) that activate 
should take a parameter as the id of some object I want to resurrect.


No doubt, I'll get used to it.
Ciao,
Jonathan

On 16/01/2009 15:55, Thiago HP wrote:

On Fri, Jan 16, 2009 at 1:42 PM, Jonathan O'Connorninki...@eircom.net  wrote:
   

Hi,
 


Hi!

   

I have been reading the documentation, and I haven't seen what I need to
find out: How can a page finding that the user is not logged in, it should
jump to a login page, and optionally jump back to the requested page?
 


Use onActivate. One way to do it:

@InjectPage
private LoginPage loginPage;

Object onActivate() {
 if (user is not logged in) {
 // you could set any properties in the login page here.
 return loginPage;
 }
 else {
 return null; // continue rendering this page normally.
 }
}

On the other hand, if you need this behaviour to be applied to more
than one page, a RequestFilter would be the best way, as this would
put all the code in a single place and the pages wouldn't need to
bother with this issues. In this mailing list you can find some
examples, maybe in the wiki too. ;)

   


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



Re: Where to check that the user is logged in when rendering a page

2009-01-16 Thread Thiago HP
On Fri, Jan 16, 2009 at 2:14 PM, Jonathan O'Connor ninki...@eircom.net wrote:
 Thiago,
 thanks very much.

You're welcome!

 b) I feel (due to the examples in the documentation) that activate should
 take a parameter as the id of some object I want to resurrect.

onActivate is a method that handles (is invoked) the activate event: a
page was requested and is about to be rendered. Receiving activation
context parameters is just a bonus. :)

 Ciao,

Ciao! (That's the Italian way to write it. Brazilians pronounce it
always the same, but write tchau.)

-- 
Thiago

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



Re: Where to check that the user is logged in when rendering a page

2009-01-16 Thread Thiago HP
On Fri, Jan 16, 2009 at 1:42 PM, Jonathan O'Connor ninki...@eircom.net wrote:
 Hi,

Hi!

 I have been reading the documentation, and I haven't seen what I need to
 find out: How can a page finding that the user is not logged in, it should
 jump to a login page, and optionally jump back to the requested page?

Use onActivate. One way to do it:

@InjectPage
private LoginPage loginPage;

Object onActivate() {
if (user is not logged in) {
// you could set any properties in the login page here.
return loginPage;
}
else {
return null; // continue rendering this page normally.
}
}

On the other hand, if you need this behaviour to be applied to more
than one page, a RequestFilter would be the best way, as this would
put all the code in a single place and the pages wouldn't need to
bother with this issues. In this mailing list you can find some
examples, maybe in the wiki too. ;)

-- 
Thiago

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



Re: Where to check that the user is logged in when rendering a page

2009-01-16 Thread Joachim Van der Auwera

I would recommend checking out chenillekit-access.
See http://www.chenillekit.org/chenillekit-access/index.html
Documentation is minimal, but there is an example in the source code.

Kind regards,
Joachim

Jonathan O'Connor wrote:

Hi,
I have been reading the documentation, and I haven't seen what I need 
to find out: How can a page finding that the user is not logged in, it 
should jump to a login page, and optionally jump back to the requested 
page?


I already know how to check the session to see if a) there is a 
session, and b) that a user logged in correctly. What I need to know is:
1. What method/annotation do I need to write in my page class before 
the page renders
2. Presumably, I want to return a Page or a URL from this method, to 
redirect to the login page.
3. Should the login page take a hidden field to say which page it 
wants to go to next?


BTW, I would love to see, in one place, a list of all the methods 
added by the classloader, how it was triggered. The list I know about 
are:
1. Component Rendering Methods: setupRender, beginRender, 
beforeRenderTemplate, beforeRenderBody, afterRenderBody, 
afterRenderTemplate, afterRender, cleanupRender.

2. Page Lifecycle methods: pageLoaded, pageAttached, pageDetached
3. Page activation events: onActivate, onPassivate
4. Action events: onActionFromBlah, onSubmit
5. Form events: prepareForRender, prepare, prepareForSubmit, 
onValidate, onSuccess, onFailure, onSubmit

6. getters and setters of @Property annotated private attributes.

No doubt I've missed a few more.
Thanks,
Jonathan

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




--
Joachim Van der Auwera
PROGS bvba, progs.be


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