GeeCON Prague 2014*
The moose likes Other Application Frameworks and the fly likes Simple login/logout tutorial for Tapestry? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Simple login/logout tutorial for Tapestry?" Watch "Simple login/logout tutorial for Tapestry?" New topic
Author

Simple login/logout tutorial for Tapestry?

Daniil Sosonkin
Ranch Hand

Joined: Jan 15, 2004
Posts: 76
Hello,

I'm looking to write quite a system in JSP/Servlets, but this time I'd like to use some kind of framework. When writing stuff using good old Java I end up writing part of Tapestry or JSF and such. After looking at frameworks available, I find Tapestry the most appealing (mainly because designers do not touch/see code). But the trouble for me is to get off the ground. All pages on the site will be password protected. So no matter where you go, you must be logged in. But I just can't find a good tutorial which will show me how to login/logout user (or even how to make a single logon). Everyone just keeps showing simple examples and benefits of the framework - please, can anyone give me a sample of how I can do login/logout w/ User object in memory? I'm all confused on where to start.

Many thanks!
Martijn Dashorst
author
Ranch Hand

Joined: Jan 23, 2006
Posts: 58
Originally posted by Daniil Sosonkin:
Hello,

I'm looking to write quite a system in JSP/Servlets, but this time I'd like to use some kind of framework. When writing stuff using good old Java I end up writing part of Tapestry or JSF and such. After looking at frameworks available, I find Tapestry the most appealing (mainly because designers do not touch/see code). But the trouble for me is to get off the ground. All pages on the site will be password protected. So no matter where you go, you must be logged in. But I just can't find a good tutorial which will show me how to login/logout user (or even how to make a single logon). Everyone just keeps showing simple examples and benefits of the framework - please, can anyone give me a sample of how I can do login/logout w/ User object in memory? I'm all confused on where to start.

Many thanks!


Though I'm not an expert, nor user of the Tapestry framework, I guess you can add an User object to the session and check for that in each request cycle. If the user is not present, go to the login page. When the user needs to log out, set the User object on the session to null.

Using Wicket code (SHAMELESS PLUG, I know) you would do something like this:


And have all pages in your application extend MyBasePage.

I know Tapestry has some similar concept, but as I said, I'm not a Tapestry expert.
Daniil Sosonkin
Ranch Hand

Joined: Jan 15, 2004
Posts: 76
Yes, they all have similar concept - you put an object into the session But I'm looking for Tapestry in particular because I've already chosen this framework. Wicket was also considered, but I giving designers more freedom w/ least feedback on my side.
Anselm Paulinus
Ranch Hand

Joined: Sep 05, 2003
Posts: 389
If you are actually evaluating Tapestry; then you might consider putting the user object in the vist when a user logs in and at log out you invalidate the user object in your visit. Now remember to include your visit object in you .application because Tapestry will not do it for you, else you wont be able to instantiate the visit object.

Hope this helps.
Martijn Dashorst
author
Ranch Hand

Joined: Jan 23, 2006
Posts: 58
Originally posted by Daniil Sosonkin:
Yes, they all have similar concept - you put an object into the session But I'm looking for Tapestry in particular because I've already chosen this framework. Wicket was also considered, but I giving designers more freedom w/ least feedback on my side.


I didn't want to force you into W. It is just that I'm not familiar with Tapestry enough, but know the concepts. Just not the names. I think Tapestry is a great framework and an excellent choice (just not the best one ).

Visit /does/ ring a bell though.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Chapter 4 of Kent Tong's book shows you what you want to know. It's one of the free chapters. The whole book is worth every cent of $20 though.


GenRocket - Experts at Building Test Data
Daniil Sosonkin
Ranch Hand

Joined: Jan 15, 2004
Posts: 76
Thanks everyone I actually got it figured out. Its my first step into frameworks in general (after years of dev in JSP/Servlets). Just takes time to get used to. Yeah, have to purchase that book - is it the only one? - just got to find time.

I've created a User object as soon as I began (seemed obvious) just didn't know where exactly to stick it or where should I check for it. Funny, I'd think that a framework would provide some build-in way of doing something so rudimentary.
Daniil Sosonkin
Ranch Hand

Joined: Jan 15, 2004
Posts: 76
Ooops, I just realized that I confused Wicket with Echo! Wicket does look great... I'll have to take a closer look into it. Thanx!
Daniil Sosonkin
Ranch Hand

Joined: Jan 15, 2004
Posts: 76
Wicket is very close to Tapestry. But unfortunately I can't get it run on Tomcat. It never finds an HTML template on me. No matter where I put it.
Martijn Dashorst
author
Ranch Hand

Joined: Jan 23, 2006
Posts: 58
Originally posted by Daniil Sosonkin:
Wicket is very close to Tapestry. But unfortunately I can't get it run on Tomcat. It never finds an HTML template on me. No matter where I put it.


The default for Wicket is to search for your templates next to your java classes, in the same package directory.

So if your web page is: com.foo.pages.Index
then it will look for com/foo/pages/Index.html

Have you looked at the tutorials at JavaLobby? They have an excellent primer...

Wicket: what's that buzz?
Martijn Dashorst
author
Ranch Hand

Joined: Jan 23, 2006
Posts: 58
BTW, a more detailed response can be found here (Javalobby.org)
 
GeeCON Prague 2014
 
subject: Simple login/logout tutorial for Tapestry?