Hi, Tvedt! 
The thing is that from
localhost:8080 it can't go to anywhere ( i don't know the reason for it )
but from 
localhost:8080/about ( or any other page ) links work just fine and don't broke

My code for links is just fine, and I see no reason why it's not working in the 
one case, and works in the next.
Maybe, following code is 
public class ProtectPageService implements Dispatcher {

    private final static String LOGIN_PAGE = "/";
    private ApplicationStateManager applicationStateManager;
    private final ComponentClassResolver componentClassResolver;
    private final ComponentSource componentSource;

    public ProtectPageService(ApplicationStateManager asm, 
ComponentClassResolver resolver, ComponentSource componentSource) {
        this.applicationStateManager = asm;
        this.componentClassResolver = resolver;
        this.componentSource = componentSource;
    }

    public boolean dispatch(Request request, Response response) throws 
IOException {
        /*
         * We need to get the Tapestry page requested by the user. So we parse 
the path extracted from the request
         */
        String path = request.getPath();
        int nextslashx = path.length();
        String pageName;

        while (true) {
            pageName = path.substring(1, nextslashx);
            if (!pageName.endsWith("/") && 
componentClassResolver.isPageName(pageName)) {
                break;
            }
            nextslashx = path.lastIndexOf('/', nextslashx - 1);
            if (nextslashx <= 1) {
                return false;
            }
        }
        return checkAccess(pageName, request, response);
    }

    public boolean checkAccess(String pageName, Request request, Response 
response) throws IOException {
        boolean canAccess = true;

        /* Is the requested page private ? */
        Component page = componentSource.getPage(pageName);
        boolean protectedPage = 
page.getClass().getAnnotation(ProtectedPage.class) != null;

        if (protectedPage) {
            canAccess = false;
            // If a Visit already exists in the session then you have already 
been authenticated
            if (applicationStateManager.exists(User.class)) {
                boolean adminPage = isAdminPage(page);
                User userCurrent= 
applicationStateManager.getIfExists(User.class);
                if (adminPage && userCurrent.getRola() == UserType.ADMIN) {
                    canAccess = true;
                } else if (adminPage) {
                    canAccess = false;
                } else {
                    canAccess = true;
                }
            }
        }
        /*
         * This page can't be requested by a non-authenticated user => we 
redirect him to the LogIn page
         */
        if (!canAccess) {
            response.sendRedirect(request.getContextPath() + LOGIN_PAGE);
            return true; // Make sure to leave the chain
        }
        return false;
    }

One more note is that this scenario occurs when I deploy my app as ROOT, ie ( 
localhost:8080 )

> Date: Sun, 28 Jul 2013 05:11:43 +0200
> Subject: RE: Index broken reference
> From: sigbjo...@gmail.com
> To: users@tapestry.apache.org
> 
> Hi.
> Could you please post the error message/stacktraces and the code that you
> are using?
> 
> Regards
> Sigbjørn Tvedt
> On 27 Jul 2013 20:15, "Nomen Nominus" <geribi...@outlook.com> wrote:
> 
> > What have I observed is that when I click on Home( Index page ) it gets me
> > to localhost:8080 , and it can't link to anything from there. But in any
> > other case like the following scenario localhost:8080/*(any page here ) and
> > links to any other page works just fine from there.
> >
> > > From: geribi...@outlook.com
> > > To: users@tapestry.apache.org
> > > Subject: Index broken reference
> > > Date: Sat, 27 Jul 2013 16:02:29 +0100
> > >
> > > I have an issue with my Index page onEvent link. My app event links
> > > works just fine, however, when I click on my home page ( which is an
> > > index page ) I get to Index, but when I click any of the event or action
> > >  links after, I get broken reference ( index.layout.menu.goabout ). What
> > may
> > > be the cause of it, it's driving me crazy...
> >
                                          

Reply via email to