Re: Session... when are they created?
On 11 Aug 2009, at 11:47, Francesco Romano wrote: I noticed that the submit button has no wosid associated, but the other links yes... Therein lies the problem I think. It should have a wosid. You need to figure out why that link is not getting the wosid appended correctly. What happens if you remove the '?redirect = redirectTo' bindings from both the form and the button? Mark ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Session... when are they created?
that's the thing... while you may have a "session," somewhere that's relevant to your current user interaction, the page/context you're calling session() on may not have it; so, if you hit session() when the page/context doesn't hasSession(), you'll get a new lazily created session object there is, in my opinion, a bug related to lazily generating sessions at certain times during the RR-Loop; which can push a session into a state which isn't registered correctly with your app --- make sure you check hasSession(), and don't access session() if it ins't there, even in you feel it should be --- this will make you and your app happier -g On Aug 10, 2009, at 3:36 AM, Francesco Romano wrote: I read that page... I added in the session constructor a log... But I can't understand why even if I have a session, calling an action create another session (and context.hasSession says that there is no session... so.. it seems like I'm losing a session).. Francesco On 07/ago/09, at 16:16, George Domurot wrote: Take a looks at this page: http://wiki.objectstyle.org/confluence/display/WO/Debugging+the+Request-Response+Loop In particular, update your session constructor to monitor exactly where/when sessions are being created (see code snip on page). There are cases where you end up lazily creating sessions when not intending to, that then somehow are detached or unregistered correctly, and they will never timeout. Before accessing your session, there may be a spot in your code where you should check hasSession() first. -George On Aug 7, 2009, at 3:11 AM, Francesco Romano wrote: Hi... I've 2 problems with sessions... 1) When are they created? I thought that they are created either when you call the session() method or when you use some component that need a session... I don't understand why a new session is created calling this page: "app" /> p> Learn More Descrizione p> prezzoString: WOString { value = product.prezzo; numberformat = "$ 0.00"; } The page wrapper should not create a session (I use it in every page, and it not create a session...) That page is called from this: productLink: WOHyperlink { directActionName = "showProduct"; actionClass = "DirectAction"; ?product = aProduct.prodID; } public WOActionResults showProductAction() { WOComponent nextPage = pageWithName(ShowProduct.class); nextPage.takeValueForKey(request().formValueForKey("product"), "product"); return nextPage; } I'm sure that some days ago it worked 2) Let's say an anonymous user has a session... then he logs in. And... I don't want the session change!! This is the code (it's a direct action, called from a submit button in a form) public WOActionResults doLoginAction() { WOComponent nextPage = null; EOEditingContext ec = ERXEC.newEditingContext(); String username = (String) request().formValueForKey("username"); String password = (String) request().formValueForKey("password"); Object redirect = request().formValueForKey("redirect"); Cliente user = Cliente.fetchCliente(ec, Cliente.EMAIL.eq (username)); if (user == null) { //errore.. utente nn trovato; nextPage = pageWithName(LoginPage.class); nextPage.takeValueForKey("utente non trovato", "error"); nextPage.takeValueForKey(username, "username"); nextPage.takeValueForKey(redirect, "redirectTo"); return nextPage; } if (! user.password().equals(password)) { //errore.. password sbagliata nextPage = pageWithName(LoginPage.class); nextPage.takeValueForKey("password sbagliata", "error"); nextPage.takeValueForKey(username, "username"); nextPage.takeValueForKey(redirect, "redirectTo"); return nextPage; } if (user.activationDate() != 0) { //errore.. utente non attivo nextPage = pageWithName(LoginPage.class); nextPage.takeValueForKey("Utente non ancora attivo. Per favore procedi con l'attivazione", "error"); nextPage.takeValueForKey(username, "username"); nextPage.takeValueForKey(redirect, "redirectTo"); return nextPage; } ERXApplica
Re: Session... when are they created?
I think I handle sessions in the default way (not with cookies.. maybe in the future if I need to save something in the client-side..). This is what I'm doing: The user select a category (direct action, no session), the user want to see a product (direct action, no session), the user add a product to a cart (direct action but I create the session). Now.. the user wants to log in... (direct action, have a session BUT during the direct action "doLogin" it seems it doesn't have a session and another is created).. Direct actions are handled by the class DirectAction, but all the direct actions related to login are handled by a Login class. This is the login form: Username: Password:tr> loginForm: WOForm { name = "loginForm"; actionClass = "Login"; directActionName = "doLogin"; ?redirect = redirectTo; } userField: WOTextField { name = "username"; value = username; } passwordField: WOPasswordField { name = "password"; value = password; } loginButton: WOSubmitButton { actionClass = "Login"; directActionName = "doLogin"; ?redirect = redirectTo; } Now.. I noticed that the url show the action name and not the page name, after the login... http://192.168.1.87:5100/cgi-bin/WebObjects/PNStore.woa/wa/Login/doLogin but I'm in the showAccount page... Francesco On 10/ago/09, at 20:03, Mark Gowdy wrote: 2) Let's say an anonymous user has a session... then he logs in. And... I don't want the session change!! This is the code (it's a direct action, called from a submit button in a form) In the case where the user has a session, can you show us: 1) The component html (in eclipse) for this login form. 2) And can you show us the rendered html source from the browser and the URL that got you to that login page. Are sessions being handled in the default way, or are you using cookies (or another way)? Regards, Mark ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Session... when are they created?
2) Let's say an anonymous user has a session... then he logs in. And... I don't want the session change!! This is the code (it's a direct action, called from a submit button in a form) In the case where the user has a session, can you show us: 1) The component html (in eclipse) for this login form. 2) And can you show us the rendered html source from the browser and the URL that got you to that login page. Are sessions being handled in the default way, or are you using cookies (or another way)? Regards, Mark ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Session... when are they created?
I read that page... I added in the session constructor a log... But I can't understand why even if I have a session, calling an action create another session (and context.hasSession says that there is no session... so.. it seems like I'm losing a session).. Francesco On 07/ago/09, at 16:16, George Domurot wrote: Take a looks at this page: http://wiki.objectstyle.org/confluence/display/WO/Debugging+the+Request-Response+Loop In particular, update your session constructor to monitor exactly where/when sessions are being created (see code snip on page). There are cases where you end up lazily creating sessions when not intending to, that then somehow are detached or unregistered correctly, and they will never timeout. Before accessing your session, there may be a spot in your code where you should check hasSession() first. -George On Aug 7, 2009, at 3:11 AM, Francesco Romano wrote: Hi... I've 2 problems with sessions... 1) When are they created? I thought that they are created either when you call the session() method or when you use some component that need a session... I don't understand why a new session is created calling this page: "app" /> > Learn More Descrizione prezzoString: WOString { value = product.prezzo; numberformat = "$ 0.00"; } The page wrapper should not create a session (I use it in every page, and it not create a session...) That page is called from this: productLink: WOHyperlink { directActionName = "showProduct"; actionClass = "DirectAction"; ?product = aProduct.prodID; } public WOActionResults showProductAction() { WOComponent nextPage = pageWithName(ShowProduct.class); nextPage.takeValueForKey(request().formValueForKey("product"), "product"); return nextPage; } I'm sure that some days ago it worked 2) Let's say an anonymous user has a session... then he logs in. And... I don't want the session change!! This is the code (it's a direct action, called from a submit button in a form) public WOActionResults doLoginAction() { WOComponent nextPage = null; EOEditingContext ec = ERXEC.newEditingContext(); String username = (String) request().formValueForKey("username"); String password = (String) request().formValueForKey("password"); Object redirect = request().formValueForKey("redirect"); Cliente user = Cliente.fetchCliente(ec, Cliente.EMAIL.eq(username)); if (user == null) { //errore.. utente nn trovato; nextPage = pageWithName(LoginPage.class); nextPage.takeValueForKey("utente non trovato", "error"); nextPage.takeValueForKey(username, "username"); nextPage.takeValueForKey(redirect, "redirectTo"); return nextPage; } if (! user.password().equals(password)) { //errore.. password sbagliata nextPage = pageWithName(LoginPage.class); nextPage.takeValueForKey("password sbagliata", "error"); nextPage.takeValueForKey(username, "username"); nextPage.takeValueForKey(redirect, "redirectTo"); return nextPage; } if (user.activationDate() != 0) { //errore.. utente non attivo nextPage = pageWithName(LoginPage.class); nextPage.takeValueForKey("Utente non ancora attivo. Per favore procedi con l'attivazione", "error"); nextPage.takeValueForKey(username, "username"); nextPage.takeValueForKey(redirect, "redirectTo"); return nextPage; } ERXApplication.log.info(context().hasSession()); // it returns false user = (Cliente) EOUtilities .localInstanceOfObject(session().defaultEditingContext(), user); ERXApplication.log.info(context().hasSession()); // it returns true ((Session)session()).setUser(user); if (redirect.equals("account")) nextPage = pageWithName(AccountPage.class); return nextPage; } The problem is that it seems he don't have a session..(tested in the context.hasSession()).. but.. this is the log: Aug 07 12:08:08 PNStore[5100] INFO er.extensions.appserver.ERXApplication - Created Session xqBvrhS2xvYiy2k7g
Re: Session... when are they created?
I didn't notice it before... Is it possible to pass an object to a Direct Action? Or I can only pass strings? sure . if you have a session :) What I want is that until a user press that hyperlink I don't want to have a session, but if the user press the link.. I need the session.. you will need to make that a direct action link that passes the ID of the item. ms ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Session... when are they created?
Take a looks at this page: http://wiki.objectstyle.org/confluence/display/WO/Debugging+the+Request-Response+Loop In particular, update your session constructor to monitor exactly where/when sessions are being created (see code snip on page). There are cases where you end up lazily creating sessions when not intending to, that then somehow are detached or unregistered correctly, and they will never timeout. Before accessing your session, there may be a spot in your code where you should check hasSession() first. -George On Aug 7, 2009, at 3:11 AM, Francesco Romano wrote: Hi... I've 2 problems with sessions... 1) When are they created? I thought that they are created either when you call the session() method or when you use some component that need a session... I don't understand why a new session is created calling this page: "app" /> > Learn More Descrizione prezzoString: WOString { value = product.prezzo; numberformat = "$ 0.00"; } The page wrapper should not create a session (I use it in every page, and it not create a session...) That page is called from this: productLink: WOHyperlink { directActionName = "showProduct"; actionClass = "DirectAction"; ?product = aProduct.prodID; } public WOActionResults showProductAction() { WOComponent nextPage = pageWithName(ShowProduct.class); nextPage.takeValueForKey(request().formValueForKey("product"), "product"); return nextPage; } I'm sure that some days ago it worked 2) Let's say an anonymous user has a session... then he logs in. And... I don't want the session change!! This is the code (it's a direct action, called from a submit button in a form) public WOActionResults doLoginAction() { WOComponent nextPage = null; EOEditingContext ec = ERXEC.newEditingContext(); String username = (String) request().formValueForKey("username"); String password = (String) request().formValueForKey("password"); Object redirect = request().formValueForKey("redirect"); Cliente user = Cliente.fetchCliente(ec, Cliente.EMAIL.eq(username)); if (user == null) { //errore.. utente nn trovato; nextPage = pageWithName(LoginPage.class); nextPage.takeValueForKey("utente non trovato", "error"); nextPage.takeValueForKey(username, "username"); nextPage.takeValueForKey(redirect, "redirectTo"); return nextPage; } if (! user.password().equals(password)) { //errore.. password sbagliata nextPage = pageWithName(LoginPage.class); nextPage.takeValueForKey("password sbagliata", "error"); nextPage.takeValueForKey(username, "username"); nextPage.takeValueForKey(redirect, "redirectTo"); return nextPage; } if (user.activationDate() != 0) { //errore.. utente non attivo nextPage = pageWithName(LoginPage.class); nextPage.takeValueForKey("Utente non ancora attivo. Per favore procedi con l'attivazione", "error"); nextPage.takeValueForKey(username, "username"); nextPage.takeValueForKey(redirect, "redirectTo"); return nextPage; } ERXApplication.log.info(context().hasSession()); // it returns false user = (Cliente) EOUtilities.localInstanceOfObject(session ().defaultEditingContext(), user); ERXApplication.log.info(context().hasSession()); // it returns true ((Session)session()).setUser(user); if (redirect.equals("account")) nextPage = pageWithName(AccountPage.class); return nextPage; } The problem is that it seems he don't have a session..(tested in the context.hasSession()).. but.. this is the log: Aug 07 12:08:08 PNStore[5100] INFO er.extensions.appserver.ERXApplication - Created Session xqBvrhS2xvYiy2k7g00IMg ... Aug 07 12:08:19 PNStore[5100] INFO er.extensions.appserver.ERXApplication - false Aug 07 12:08:19 PNStore[5100] INFO er.extensions.appserver.ERXApplication - Created Session tucshimhkohHUgesq7l9nw Aug 07 12:08:19 PNStore[5100] INFO er.extensions.appserver.ERXApplication - tr
Re: Session... when are they created?
On 07/ago/09, at 14:08, Mike Schrag wrote: I didn't notice it before... Is it possible to pass an object to a Direct Action? Or I can only pass strings? What I want is that until a user press that hyperlink I don't want to have a session, but if the user press the link.. I need the session.. Francesco On Aug 7, 2009, at 6:11 AM, Francesco Romano wrote: Hi... I've 2 problems with sessions... 1) When are they created? I thought that they are created either when you call the session() method or when you use some component that need a session... I don't understand why a new session is created calling this page: "app" /> > Learn More Descrizione prezzoString: WOString { value = product.prezzo; numberformat = "$ 0.00"; } The page wrapper should not create a session (I use it in every page, and it not create a session...) That page is called from this: productLink: WOHyperlink { directActionName = "showProduct"; actionClass = "DirectAction"; ?product = aProduct.prodID; } public WOActionResults showProductAction() { WOComponent nextPage = pageWithName(ShowProduct.class); nextPage.takeValueForKey(request().formValueForKey("product"), "product"); return nextPage; } I'm sure that some days ago it worked 2) Let's say an anonymous user has a session... then he logs in. And... I don't want the session change!! This is the code (it's a direct action, called from a submit button in a form) public WOActionResults doLoginAction() { WOComponent nextPage = null; EOEditingContext ec = ERXEC.newEditingContext(); String username = (String) request().formValueForKey("username"); String password = (String) request().formValueForKey("password"); Object redirect = request().formValueForKey("redirect"); Cliente user = Cliente.fetchCliente(ec, Cliente.EMAIL.eq(username)); if (user == null) { //errore.. utente nn trovato; nextPage = pageWithName(LoginPage.class); nextPage.takeValueForKey("utente non trovato", "error"); nextPage.takeValueForKey(username, "username"); nextPage.takeValueForKey(redirect, "redirectTo"); return nextPage; } if (! user.password().equals(password)) { //errore.. password sbagliata nextPage = pageWithName(LoginPage.class); nextPage.takeValueForKey("password sbagliata", "error"); nextPage.takeValueForKey(username, "username"); nextPage.takeValueForKey(redirect, "redirectTo"); return nextPage; } if (user.activationDate() != 0) { //errore.. utente non attivo nextPage = pageWithName(LoginPage.class); nextPage.takeValueForKey("Utente non ancora attivo. Per favore procedi con l'attivazione", "error"); nextPage.takeValueForKey(username, "username"); nextPage.takeValueForKey(redirect, "redirectTo"); return nextPage; } ERXApplication.log.info(context().hasSession()); // it returns false user = (Cliente) EOUtilities .localInstanceOfObject(session().defaultEditingContext(), user); ERXApplication.log.info(context().hasSession()); // it returns true ((Session)session()).setUser(user); if (redirect.equals("account")) nextPage = pageWithName(AccountPage.class); return nextPage; } The problem is that it seems he don't have a session..(tested in the context.hasSession()).. but.. this is the log: Aug 07 12:08:08 PNStore[5100] INFO er.extensions.appserver.ERXApplication - Created Session xqBvrhS2xvYiy2k7g00IMg ... Aug 07 12:08:19 PNStore[5100] INFO er.extensions.appserver.ERXApplication - false Aug 07 12:08:19 PNStore[5100] INFO er.extensions.appserver.ERXApplication - Created Session tucshimhkohHUgesq7l9nw Aug 07 12:08:19 PNStore[5100] INFO er.extensions.appserver.ERXApplication - true What is wrong?? Thanks. Francesco ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your S
Re: Session... when are they created?
Hi... I've 2 problems with sessions... 1) When are they created? I thought that they are created either when you call the session() method or when you use some component that need a session... I don't understand why a new session is created calling this page: "app" /> > Learn More Descrizione prezzoString: WOString { value = product.prezzo; numberformat = "$ 0.00"; } The page wrapper should not create a session (I use it in every page, and it not create a session...) That page is called from this: productLink: WOHyperlink { directActionName = "showProduct"; actionClass = "DirectAction"; ?product = aProduct.prodID; } public WOActionResults showProductAction() { WOComponent nextPage = pageWithName(ShowProduct.class); nextPage.takeValueForKey(request().formValueForKey("product"), "product"); return nextPage; } I'm sure that some days ago it worked 2) Let's say an anonymous user has a session... then he logs in. And... I don't want the session change!! This is the code (it's a direct action, called from a submit button in a form) public WOActionResults doLoginAction() { WOComponent nextPage = null; EOEditingContext ec = ERXEC.newEditingContext(); String username = (String) request().formValueForKey("username"); String password = (String) request().formValueForKey("password"); Object redirect = request().formValueForKey("redirect"); Cliente user = Cliente.fetchCliente(ec, Cliente.EMAIL.eq(username)); if (user == null) { //errore.. utente nn trovato; nextPage = pageWithName(LoginPage.class); nextPage.takeValueForKey("utente non trovato", "error"); nextPage.takeValueForKey(username, "username"); nextPage.takeValueForKey(redirect, "redirectTo"); return nextPage; } if (! user.password().equals(password)) { //errore.. password sbagliata nextPage = pageWithName(LoginPage.class); nextPage.takeValueForKey("password sbagliata", "error"); nextPage.takeValueForKey(username, "username"); nextPage.takeValueForKey(redirect, "redirectTo"); return nextPage; } if (user.activationDate() != 0) { //errore.. utente non attivo nextPage = pageWithName(LoginPage.class); nextPage.takeValueForKey("Utente non ancora attivo. Per favore procedi con l'attivazione", "error"); nextPage.takeValueForKey(username, "username"); nextPage.takeValueForKey(redirect, "redirectTo"); return nextPage; } ERXApplication.log.info(context().hasSession()); // it returns false user = (Cliente) EOUtilities.localInstanceOfObject(session().defaultEditingContext(), user); ERXApplication.log.info(context().hasSession()); // it returns true ((Session)session()).setUser(user); if (redirect.equals("account")) nextPage = pageWithName(AccountPage.class); return nextPage; } The problem is that it seems he don't have a session..(tested in the context.hasSession()).. but.. this is the log: Aug 07 12:08:08 PNStore[5100] INFO er.extensions.appserver.ERXApplication - Created Session xqBvrhS2xvYiy2k7g00IMg ... Aug 07 12:08:19 PNStore[5100] INFO er.extensions.appserver.ERXApplication - false Aug 07 12:08:19 PNStore[5100] INFO er.extensions.appserver.ERXApplication - Created Session tucshimhkohHUgesq7l9nw Aug 07 12:08:19 PNStore[5100] INFO er.extensions.appserver.ERXApplication - true What is wrong?? Thanks. Francesco ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/mschrag%40mdimension.com This email sent to msch...@mdimension.com ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your
Session... when are they created?
Hi... I've 2 problems with sessions... 1) When are they created? I thought that they are created either when you call the session() method or when you use some component that need a session... I don't understand why a new session is created calling this page: p> Learn More Descrizione prezzoString: WOString { value = product.prezzo; numberformat = "$ 0.00"; } The page wrapper should not create a session (I use it in every page, and it not create a session...) That page is called from this: productLink: WOHyperlink { directActionName = "showProduct"; actionClass = "DirectAction"; ?product = aProduct.prodID; } public WOActionResults showProductAction() { WOComponent nextPage = pageWithName(ShowProduct.class); nextPage.takeValueForKey(request().formValueForKey("product"), "product"); return nextPage; } I'm sure that some days ago it worked 2) Let's say an anonymous user has a session... then he logs in. And... I don't want the session change!! This is the code (it's a direct action, called from a submit button in a form) public WOActionResults doLoginAction() { WOComponent nextPage = null; EOEditingContext ec = ERXEC.newEditingContext(); String username = (String) request().formValueForKey("username"); String password = (String) request().formValueForKey("password"); Object redirect = request().formValueForKey("redirect"); Cliente user = Cliente.fetchCliente(ec, Cliente.EMAIL.eq(username)); if (user == null) { //errore.. utente nn trovato; nextPage = pageWithName(LoginPage.class); nextPage.takeValueForKey("utente non trovato", "error"); nextPage.takeValueForKey(username, "username"); nextPage.takeValueForKey(redirect, "redirectTo"); return nextPage; } if (! user.password().equals(password)) { //errore.. password sbagliata nextPage = pageWithName(LoginPage.class); nextPage.takeValueForKey("password sbagliata", "error"); nextPage.takeValueForKey(username, "username"); nextPage.takeValueForKey(redirect, "redirectTo"); return nextPage; } if (user.activationDate() != 0) { //errore.. utente non attivo nextPage = pageWithName(LoginPage.class); nextPage.takeValueForKey("Utente non ancora attivo. Per favore procedi con l'attivazione", "error"); nextPage.takeValueForKey(username, "username"); nextPage.takeValueForKey(redirect, "redirectTo"); return nextPage; } ERXApplication.log.info(context().hasSession()); // it returns false user = (Cliente) EOUtilities.localInstanceOfObject(session().defaultEditingContext(), user); ERXApplication.log.info(context().hasSession()); // it returns true ((Session)session()).setUser(user); if (redirect.equals("account")) nextPage = pageWithName(AccountPage.class); return nextPage; } The problem is that it seems he don't have a session..(tested in the context.hasSession()).. but.. this is the log: Aug 07 12:08:08 PNStore[5100] INFO er.extensions.appserver.ERXApplication - Created Session xqBvrhS2xvYiy2k7g00IMg ... Aug 07 12:08:19 PNStore[5100] INFO er.extensions.appserver.ERXApplication - false Aug 07 12:08:19 PNStore[5100] INFO er.extensions.appserver.ERXApplication - Created Session tucshimhkohHUgesq7l9nw Aug 07 12:08:19 PNStore[5100] INFO er.extensions.appserver.ERXApplication - true What is wrong?? Thanks. Francesco ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com