On Nov 28, 2008, at 11:34 PM, Francesco Romano wrote:

Thanks for the reply...

I tried something like:

reloadPage :WOJavaScript {
        scriptString = session.getJSRefresh;
        hideInComment = YES;
}

with:

public String getJSRefresh () {
                if (_mainPageNeedRefresh) {
                        _mainPageNeedRefresh = false;
                        return "window.location.reload()";
                }
                return "";
        }

(_mainPageNeedRefresh) is a boolean set to true in the login.

in the page after the login...

The problem is... it tries to redo the login.. this time without passing username and password.. so I'm redirect to the login page.. (pressing the refresh button without the script is different.. it continue to login, with the username and password)... so.. this doesn't work...

But... is there a "better" way to set the URL ?

If you are using Project Wonder (and you should be), ERXRedirect may be what you want:



PS: I'm new to mailing lists.. I reply to the list too... Is this a mistake?

No, you should always reply to the list so that others may share in the knowledge.

                                        
((Session)session()).setCurrentUser(currentUser);

                                        String pageToRedirect = 
currentUser.group().mainPage();
                                        if (pageToRedirect==null)
                                                ;
                                        else {
                                                nextPage = 
pageWithName(pageToRedirect);

ERXRedirect redirect = (ERXRedirect)pageWithName(ERXRedirect.class.getName());
redirect.setComponent(nextPage);
nextPage = redirect;


Chuck


On 28/nov/08, at 21:03, Amedeo Mantica wrote:

umh, may be just a work around,..but...

in the final page you can easity trigger a javascript call in the page that call a void in the java file... so you got a "refresh" with the /wo/ftamst681g4846.../

regards

amedeo

On 27/nov/08, at 16:59, Francesco Romano wrote:

Hi.. I'm new with WebObjects and also in web programming.
I chose WO to develop a Web Application (instead of RoR)..

Now.. I'm doing a login form.. Looking a screencast from David LeBer I moved the LoginAction from my Main.java file to DirectAction.
Everything works fine.. but ... One thing is annoying.

This is the method (I've to implement the encoding of password yet..)


        public WOActionResults loginAction() {
                        
                        WOComponent nextPage = null;
                        
                        String password = 
request().stringFormValueForKey("password");
                        String username = 
request().stringFormValueForKey("username");
                        String errorMessage = null;
                        
if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) {
                                errorMessage  = "Username o password necessari";
                                password = null;
                        }
                        else
                        
                                try {
                                        User currentUser;
                                        
EOQualifier qualifier = User.USERNAME.eq(username).and(User.PASSWORD.eq(password)); currentUser = User.fetchRequiredUser(ERXEC.newEditingContext(),qualifier);
                                        if (! currentUser.active()) {
errorMessage = "Utente attualmente disabilitato. Contattare l'amministratore";
                                                password = null;
                                                currentUser = null;
                                                nextPage = 
pageWithName(Main.class.getName());
                                                nextPage.takeValueForKey(errorMessage, 
"errorMessage");
                                                nextPage.takeValueForKey(username, 
"username");
                                                return nextPage;
                                        }
                                        
((Session)session()).setCurrentUser(currentUser);

                                        String pageToRedirect = 
currentUser.group().mainPage();
                                        if (pageToRedirect==null)
                                                ;
                                        else {
                                                nextPage = 
pageWithName(pageToRedirect);
                                        }
                
                                        
                                }
                                catch (NoSuchElementException e) {
                                        errorMessage = "Utente non trovato o 
password sbagliata";
                                }
                                catch (Exception e) {
                                        NSLog.out.appendln("Some exceptions during 
login");
                                }
                                
                                if (! StringUtils.isEmpty(errorMessage)) {
                                        nextPage = 
pageWithName(Main.class.getName());
                                        nextPage.takeValueForKey(errorMessage, 
"errorMessage");
                                        nextPage.takeValueForKey(username, 
"username");
                                }
                        
                        return nextPage;
                }

Then... this is the URL after the action:
http://192.168.1.2:5100/cgi-bin/WebObjects/iPN.woa/wa/login
even when it's redirect to the WOComponent...
If someone refresh the page, a new login action is done, changing the session.
I'd like to have, after the login, the url changed to something like
 
http://192.168.1.2:5100/cgi-bin/WebObjects/iPN.woa/wo/xmxE5KfCss9XG4PiGGzmUg/0.0.5.1
so if someone press refresh the login action is not called...


Any help?

_______________________________________________
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/amedeomailing%40insigno.it

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/chill%40global-village.net

This email sent to [EMAIL PROTECTED]

--
Chuck Hill             Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects






_______________________________________________
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