Re: Web Application Platform
"Malcolm Edgar" <[email protected]>
| Newsgroups | gmane.comp.java.tapestry.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Lennart,
Please take a look the Vlib example and its use to ICallback interface:
public class net.sf.tapestry.vlib.Protected extends BasePage .. {
..
/**
* Checks if the user is logged in. If not, they are sent
* to the {@link Login} page before coming back to whatever this
* page is.
*
**/
public void validate(IRequestCycle cycle) throws RequestCycleException
{
Visit visit = (Visit) getVisit();
if (visit != null && visit.isUserLoggedIn())
return;
// User not logged in ... redirect through the Login page.
Login login = (Login) cycle.getPage("Login");
login.setCallback(new PageCallback(this));
throw new PageRedirectException(login);
}
..
}
public class net.sf.tapestry.vlib.pages.Login extends BasePage .. {
..
private ICallback callback;
public void setCallback(ICallback value)
{
callback = value;
fireObservedChange("callback", value);
}
public ICallback getCallback()
{
return callback;
}
..
/**
* Sets up the {@link Person} as the logged in user, creates
* a cookie for thier email address (for subsequent logins),
* and redirects to the appropriate page ({@link MyLibrary}, or
* a specified page).
*
**/
public void loginUser(Person person, IRequestCycle cycle)
throws RequestCycleException, RemoteException
{
..
// After logging in, go to the MyLibrary page, unless otherwise
// specified.
if (callback == null)
cycle.setPage("MyLibrary");
else
callback.performCallback(cycle);
..
}
}
regards Malcolm
p.s. we really need to document this in the DevelopersGuide
>From: Lennart Benoot <[email protected]>
>To: [email protected]
>CC: [email protected]
>Subject: [Tapestry-developer] Web Application Platform
>Date: Thu, 12 Dec 2002 15:28:10 +0100
>
>Hey All,
>
>I am currently in the process of defining a web application platform to
>provide web services. We have chosen Tapestry as MVC layer. I have a few
>problems I haven't been able to resolve (at least not in an elegant way):
>
>1) I want the whole application to be available only for logged in users.
>We have an existing framework for security. I think when a request comes
>in, the front controller servlet should check wether the user has logged
>in. If not, reroute the user to the login page. How do I do this in
>tapestry?
>
>2) Authorisation is also an important part of the web app platform. I would
>like to call some java-code whenever a new page is loaded. This code should
>check wether the user is allowed to access the page. If the user does not
>have the right permissions, he is rerouted to some other page. What would
>be a good way to do this?
>
>Thanks in advance,
>Lennart
>
>
>
>-------------------------------------------------------
>This sf.net email is sponsored by:
>With Great Power, Comes Great Responsibility Learn to use your power at
>OSDN's High Performance Computing Channel
>http://hpc.devchannel.org/
>_______________________________________________
>Tapestry-developer mailing list
>[email protected]
>https://lists.sourceforge.net/lists/listinfo/tapestry-developer
_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE*
http://join.msn.com/?page=features/junkmail
-------------------------------------------------------
This sf.net email is sponsored by:
With Great Power, Comes Great Responsibility
Learn to use your power at OSDN's High Performance Computing Channel
http://hpc.devchannel.org/