You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by triswork <tr...@gmail.com> on 2009/03/06 10:37:45 UTC

A massive flaw in my understanding of Wicket

Hi 

I am new to wicket and have run into a problem in the development of my
application. The problem has a few workarounds, but I am afraid it is
pointing to a far larger gap in my understanding of Wicket. If anyone can
tell my what is going on here, I will be *very* grateful. I put together a
test app to illustrate:

public class TestPage1 extends TestBasePage
{
    public TestPage1()
    {
        User user = MySession.get().getUser();
        String userDescription = (user == null? "No User" :
user.toString());

        add(new Link("login")
        {
            @Override
            public void onClick()
            {
                MySession.get().setUser(new User(1, "Mr", "T", "Test",
"test@test.com", "12", "test", "test"));
                setResponsePage(getApplication().getHomePage());
            }

            @Override
            public boolean isVisible()
            {
                return !MySession.get().isAuthenticated();
            }

        });

        add(new Label("user", userDescription));

//        add(new Link("logout")
//        {
//            @Override
//            public void onClick()
//            {
//                MaiaSession.get().invalidate();
//                setResponsePage(getApplication().getHomePage());
//            }
//
//            @Override
//            public boolean isVisible()
//            {
//                return MySession.get().isAuthenticated();
//            }
//        });

        add(new BookmarkablePageLink("logout", TestLogoutPage.class)
        {
            @Override
            public boolean isVisible()
            {
                boolean result = MySession.get().isAuthenticated();
                return result;
            }
        });
    }
}


The TestLogoutPage is very simple:
public class TestLogoutPage extends BasePage
{
    public TestLogoutPage()
    {
        MySession.get().invalidate();
        setResponsePage(getApplication().getHomePage());
    }
}

If I use the commented out code for the logout link, it works as expected.
If, however, I use the BookmarkableLink to the TestLogoutPage, the
application breaks. If I click "logout", the page doesn't refresh unless I
do it manually (F5). If I click logout again, then the page refreshes, but
any subsequent clicks (of either login or logout) give me a Page Expired
message.

I dont understand
1. Why the Bookmarkable page version isn't working and
2. Why the pages expire if I call logout multiple times.
-- 
View this message in context: http://www.nabble.com/A-massive-flaw-in-my-understanding-of-Wicket-tp22369056p22369056.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: A massive flaw in my understanding of Wicket

Posted by triswork <tr...@gmail.com>.
Hi Daniel

Thanks for that. It solves the problem completely. I still don't understand,
however, what actually happens under-the-hood (i.e. What does Wicket do if I
don't call setRedirect(true) - and why does this break my application?)

Regards,

Tristan



Daniel Peters-2 wrote:
> 
> Hi tristan,
> 
> try adding setRedirect(true) before calling setResponsePage. I think that
> should work:
> 
> public TestLogoutPage()
> {
>         MySession.get().invalidate();
> 	setRedirect(true); // <---
>         setResponsePage(getApplication().getHomePage());
> }
> 
> 
> regards
> Daniel
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/A-massive-flaw-in-my-understanding-of-Wicket-tp22369056p22371850.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: A massive flaw in my understanding of Wicket

Posted by Daniel Peters <da...@idealo.de>.
Hi tristan,

try adding setRedirect(true) before calling setResponsePage. I think that should work:

public TestLogoutPage()
{
        MySession.get().invalidate();
	setRedirect(true); // <---
        setResponsePage(getApplication().getHomePage());
}


regards
Daniel

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org