开发者

Wicket Sessions

I got a form and some text that is shown, after you submit the form. At the moment it does the following:

User1 types some text and submits the form -> get some result User2 enters the site and sees the input from User1 -> has to delete the input and types his own -> get a new result ...

I think you get the problem, User2 should not see the input of User1! Additionally I want to store the entered input for User1. So if he returns to the site he should be able to see his own data and nothing else!

I think I have to deal with sessions here - I heared Wicket is doing well with sessions, but I'm not able to get it working. I tryed something like that:

public class MainStartApplication extends WebApplication {
    @Override
    public Session newSession(final Request request, final Response response) {
        return new MySession(request);
    }

     @Override
    public Class<? extends WebPage> getHomePage() {
        MySession.get().setUserId(user);
    }
}

public class MySes开发者_运维问答sion extends WebSession {
    private static final long   serialVersionUID    = 1L;
    private String              userId;

    public MySession(final Request request) {
        super(request);
    }

    public static MySession get() {
        return (MySession) WebSession.get();
    }

    public void setUserId(final String userId) {
        this.userId = userId;
    }

    public String getUserId() {
        return userId;
    }      
}

But it doens't work. (No errors)

Maybe you can give me some hints?

P.S. Im working with Tomcat v6!


Wicket does a fair amount of session handling properly without you needing to muck with subclassing the WebApplication and WebSession.

It would be better if you posted the form and view code that's giving you trouble, and let us help diagnose the real issue.

There are of course situations where it's right to subclass these, but it's not clear to me that you've got that need.

If you in fact do need to do something in the session, exactly what you need to do will be clearer from the context of the base problem.


Wicket has a very nice session handling, just as @Don Roby said. I am using wicket session mainly to store user information once user signed in. And i can get the info anytime as long as the user is still have the session active.

Maybe this link can help you out : Wicket Custom WebSession

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜