Rui Pacheco wrote:
> I implement a class called AbstractWebPage that extends BasePage and I
> store
> all functionality common to webpages there.
> 
> I guess, as Geoff sugested, I'll created another abstract web page that
> deals uniquely with pages that need authentication.

This is what I suggested too. If you've put your authentication listener
in AbstractWebPage then your Login page cannot extend it any more.

If you want authenticated pages and Login page share common
functionality you have to move the authentication listener down in the
class hierarchy i.e. to AbstractAuthenticatedWebPage.

This would look like this:

public class AbstractWebPage
        extends BasePage
{
  common functionality hoes here
}


public class AbstractAuthenticatedWebPage
        extends AbstractWebPage
{
.. pageValidate authentication check listener goes here
}


public class LoginPage
        extends AbstractWebPage
{
.. some login listener goes logic here - no auth check done
}

public class SomeAppPage
        extends AbstractAuthenticatedWebPage
{
... application page that check whether user has logged in

}


Another approach is to create simple non-html component, lets call it
AuthenticationRequired and place it in pages which does require
authentication. This may be better than page hierarchy approach if only
some of your pages require authentication.

Such component can look like this:

public abstract class AuthenticationRequired
    extends AbstractComponent
    implements PageValidateListener
{
    public void pageValidate(PageEvent event)
    {
        do some authentication check
        and redirect conditionally to login page

    }

    protected void renderComponent(IMarkupWriter writer, IRequestCycle
cycle)
    {
    // Nothing to render
    }
}


regards,
Bernard



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to