I have updated the code based on Johan's suggestion. Still no luck.
public Session newSession(Request request, Response response) { ...... Session session = new Session(request); return session; } public RequestCycle newRequestCycle(Request request, Response response) { return new WebRequestCycle(this, request, response) { if(Session.exists() && <certain condiition is met>) { <----- The method Session.exists() still returns false Session mySession = Session.get(); mySession.invalidateNow(); } }; } On Tue, Mar 11, 2008 at 12:02 PM, Johan Compagner <[EMAIL PROTECTED]> wrote: > RequestCycle is first made and the the Session is being resolved. > Because the session creation code needs the request cycle first. > So thats why your code doesn't work > > that test that you want should be done in Requestcycle.onBeginRequest > > > > On Tue, Mar 11, 2008 at 4:47 PM, Rajiv Jivan <[EMAIL PROTECTED]> wrote: > > > Yes I did. I was assuming that once newSession is called, on > > subsequent calls, the session will be set on a thread local variable. > > If that is not the case, what would be the right way to check if a > > session has been created. > > > > On Tue, Mar 11, 2008 at 10:32 AM, Martijn Dashorst > > <[EMAIL PROTECTED]> wrote: > > > Did you read the javadoc for Session#exists() ? > > > > > > http://wicket.sourceforge.net/apidocs/wicket/Session.html#exists() > > > > > > "Checks if the Session threadlocal is set in this thread" > > > > > > So not if the session was created or not. > > > > > > Martijn > > > > > > > > > > > > > > > On 3/11/08, Rajiv Jivan <[EMAIL PROTECTED]> wrote: > > > > I am having a tough time understanding how sessions are > > > > created/managed specifically related to the calls > > > > > > > > public RequestCycle newRequestCycle(Request request, Response > > response) > > > > > > > > and > > > > > > > > public Session newSession(Request request, Response response) > > > > > > > > I am creating a new session by overriding the method newSession and > > > > doing something like > > > > > > > > public Session newSession(Request request, Response response) { > > > > ...... > > > > Session session = new Session(request); > > > > return session; > > > > } > > > > > > > > This works fine. On subsequent calls, newSession isn't called as a > > > > session is already in place. This is working as expected. > > > > > > > > What isn't working is the call > > > > to Session.exists(), this is always returning false when its invoked > > > > in the method newRequestCycle which I override. > > > > > > > > public RequestCycle newRequestCycle(Request request, Response > > response) { > > > > if(Session.exists() && <certain condiition is met>) { <----- > > The > > > > method Session.exists() is always returning false > > > > Session mySession = Session.get(); > > > > mySession.invalidateNow(); > > > > } > > > > } > > > > } > > > > > > > > Can someone explain why Session.exists() always returns false, and > > if > > > > the session truly doesn't exist why newSession isn't called after > > the > > > > first invocation > > > > > > > > > > --------------------------------------------------------------------- > > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > -- > > > Buy Wicket in Action: http://manning.com/dashorst > > > Apache Wicket 1.3.1 is released > > > Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.1 > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]