Re: DirectActions and URL
Re: DirectActions and URL
- Subject: Re: DirectActions and URL
- From: Chuck Hill <email@hidden>
- Date: Tue, 2 Dec 2008 11:22:56 -0800
On Dec 2, 2008, at 9:53 AM, Francesco Romano wrote:
I just updated... and now I find it.
But... there are some problems (I'm new.. so.. sorry if it's a noob
question..)
With this code:
String pageToRedirect = currentUser.group().mainPage();
if (! StringUtils.isEmpty(pageToRedirect)) {
nextPage = pageWithName(pageToRedirect);
NSLog.out.appendln(((Session) session()).currentUser());
}
(the old one) I can login.. and the output is:
1 row(s) processed
Dec 02 18:47:27 iPN[5100] (ERXNSLogLog4jBridge.java:46) DEBUG NSLog
- === Commit Internal Transaction
Dec 02 18:47:27 iPN[5100] (ERXNSLogLog4jBridge.java:40) INFO NSLog
- Session created: LxBq30SdCvFtn0kOJThIX0
Dec 02 18:47:27 iPN[5100] (ERXNSLogLog4jBridge.java:46) DEBUG NSLog
- === Begin Internal Transaction
Dec 02 18:47:27 iPN[5100] (ERXNSLogLog4jBridge.java:46) DEBUG NSLog
- evaluateExpression:
<com.webobjects.jdbcadaptor.PostgresqlExpression: "SELECT t0.id,
t0.c_main_page, t0.c_name, t0.c_security_level FROM t_group t0 WHERE
t0.id = ?::int4" withBindings: 1:2(id)>
Dec 02 18:47:27 iPN[5100] (ERXNSLogLog4jBridge.java:46) DEBUG NSLog
- 1 row(s) processed
Dec 02 18:47:27 iPN[5100] (ERXNSLogLog4jBridge.java:46) DEBUG NSLog
- === Commit Internal Transaction
Dec 02 18:47:27 iPN[5100] (ERXNSLogLog4jBridge.java:40) INFO NSLog
- <com.ipn.model.User pk:"18">
so.. 1 session and it prints the User fetched... of course the URL
is wrong.
Now using ERXRedirect:
String pageToRedirect = currentUser.group().mainPage();
if (! StringUtils.isEmpty(pageToRedirect)) {
nextPage = pageWithName(pageToRedirect);
ERXRedirect redirect =
(ERXRedirect)pageWithName(ERXRedirect.class.getName());
redirect.setComponent(nextPage);
nextPage = redirect;
NSLog.out.appendln(((Session) session()).currentUser());
}
the output is
DEBUG NSLog - === Commit Internal Transaction
Dec 02 18:51:02 iPN[5100] (ERXNSLogLog4jBridge.java:40) INFO NSLog
- Session created: 44xKfiKRqbM0cxKqbB3xn0
Dec 02 18:51:02 iPN[5100] (ERXNSLogLog4jBridge.java:46) DEBUG NSLog
- === Begin Internal Transaction
Dec 02 18:51:02 iPN[5100] (ERXNSLogLog4jBridge.java:46) DEBUG NSLog
- evaluateExpression:
<com.webobjects.jdbcadaptor.PostgresqlExpression: "SELECT t0.id,
t0.c_main_page, t0.c_name, t0.c_security_level FROM t_group t0 WHERE
t0.id = ?::int4" withBindings: 1:2(id)>
Dec 02 18:51:02 iPN[5100] (ERXNSLogLog4jBridge.java:46) DEBUG NSLog
- 1 row(s) processed
Dec 02 18:51:02 iPN[5100] (ERXNSLogLog4jBridge.java:46) DEBUG NSLog
- === Commit Internal Transaction
Dec 02 18:51:02 iPN[5100] (ERXNSLogLog4jBridge.java:40) INFO NSLog
- <com.ipn.model.User pk:"18">
Dec 02 18:51:02 iPN[5100] (ERXNSLogLog4jBridge.java:40) INFO NSLog
- Session created: 12qC6N7dsAt3CIDyKAwGhw
so it creates 2 sessions, it fetch the user, but:
WARN NSLog -
<com.webobjects.appserver._private.WOComponentRequestHandler>:
Exception occurred while handling request:
java.lang.NullPointerException
I got an Exception... creating the second session I don't have the
user saved in the session anymore...
Add this to you Session.java constructor:
NSLog.out.appendln(new RuntimeException());
And see where the second session is getting created.
Chuck
On 01/dic/08, at 21:52, Chuck Hill wrote:
Do you have project Wonder installed? Do you have an old version
of Project Wonder? This class was added recently.
Chuck
On Dec 1, 2008, at 12:47 PM, Francesco Romano wrote:
ERXRedirect could be the class I was looking for...
Only a ... little... problem.. Why eclipse does not see the class?
I can't find it.
On 01/dic/08, at 21:35, Chuck Hill wrote:
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 (Webobjects-
email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
--
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
--
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
--
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@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden