<wo:link action = "$addToCart"

= component action = session.

ms

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:

<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/mschrag%40mdimension.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