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:

<wo:PageWrapper title = "$pageTitle" showMerceologiaMenu = "true">
<div id = "maincontent">
<wo:ERXStyleSheet filename = "products_layout.css" framework = "app" />
<div id = "summary">
        <div id = "right_summary">
                <p><webobject name = "prezzoString"/></p>
<p><wo:link action = "$addToCart" string = "Aggiungi al carrello"/ ></p>
        </div>
        <div id = "left_summary">
                <div id = "sum_prod_title">
                        <p><wo:str value = "$product.nome"/></p>
                </div>
                <div id = "sum_prod_img">
                        <wo:img filename = "$product.photoSrc" framework = 
"app"/>
                </div>
        
                <div id = "short_desc">
                        <p><wo:str value = "$product.smallDesc" escapeHTML = 
"false"/></p>
                        <p><a href = "#long_desc">Learn More</a></p>
                </div>
                <div id="close_summary"></div>
        </div>
</div>

<div id = "long_desc">
        <p>Descrizione</p>
        <p><wo:str value = "$product.descrizione" escapeHTML = "false"/></p>

</div>
</div>
</wo:PageWrapper>

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      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/george%40boxofficetickets.com

This email sent to [email protected]


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to