Re: DirectAction + Session restoration
Re: DirectAction + Session restoration
- Subject: Re: DirectAction + Session restoration
- From: LD <email@hidden>
- Date: Thu, 1 Sep 2005 00:54:38 +1000
Hi again,
On 31/08/2005, at 11:22 PM, Kieran Kelleher wrote:
On Aug 31, 2005, at 1:02 AM, LD wrote:
On 31/08/2005, at 1:06 PM, Gavin Eadie wrote:
It's not quite the same as a recent thread related to
DirectActions and Sessions, but in researching a behavior I
didn't understand, I seem to have hit on an anomaly. OR, I've
hit on my ignorance, again. This arose when a colleague and I
were each using the same logout action from a framework -- mine
worked, his didn't; mine was triggered by a text hyperlink, his
by an image.
Demonstration:
Make a new application from the basic WebObjects application
template. On the Main page put a WOHyperink and a
WOActiveImage ... bind them both to the same DirectAction method,
say "test" for example. In the testAction method log the values
of expiredSession() and session(), in that order:
public WOActionResults testAction() {
NSLog.out.appendln(existingSession());
NSLog.out.appendln(session());
return pageWithName("Main");
}
Fire up the application and click on the hyperlink:
expiredSession() returns the session [and so does session(),
obviously]
Click on the active image:
expiredSession() returns null, and session() makes a fresh
session
Intriguing... looks like a bug, acts like a bug... well, I can't
fathom why this would occur seeing as both href's are absolutely
identical.
Something must be different in the requests generated ...... it
might be worthwhile to log the request().toString() and compare to
see if that sheds light on the problem.
You are correct.
The reason: The ISMAP attribute of the IMG tag causes an image to
function as a graphical navigation tool, when combined with an anchor
tag. From the following url we read, "WOActiveImage functions as a
_mapped_, active image"
http://developer.apple.com/documentation/WebObjects/Reference/
DynamicElements/index.html
So, the url displayed in the source is identical - but when the user
clicks the image a different url is requested. i.e., with the
additional coords. So, here's the output of each WORequest. Take note
of the wosid identified at the end of each request's string.
The culprit: the additional coords, "?8,3"
WOActiveImage-WORequest: <com.webobjects.appserver.WORequest
(<com.webobjects.appserver.WORequest httpVersion=HTTP/1.1 headers=
{user-agent = (Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-us)
AppleWebKit/412.7 (KHTML, like Gecko) Safari/412.5); accept = (*/*);
referer = (http://localhost:53049/cgi-bin/WebObjects/
TestDirectActionSession.woa); accept-encoding = (gzip, deflate); host
= (localhost:53049); accept-language = (en-us); connection = (keep-
alive); } content-length=0 cookies=null userInfo=null>) method=GET
uri=/cgi-bin/WebObjects/TestDirectActionSession.woa/wa/test?
wosid=1Q9vfb82ZtkpLxcqBLJPhM?8,3 defaultFormValueEncoding=ISO8859_1
formValueEncodingDetectionEnabled=NO formValueEncoding=ISO8859_1
formValues={wosid = ("1Q9vfb82ZtkpLxcqBLJPhM?8,3"); } >
WOHyperLink-WORequest: <com.webobjects.appserver.WORequest
(<com.webobjects.appserver.WORequest httpVersion=HTTP/1.1 headers=
{user-agent = (Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-us)
AppleWebKit/412.7 (KHTML, like Gecko) Safari/412.5); accept = (*/*);
referer = (http://localhost:53129/cgi-bin/WebObjects/
TestDirectActionSession.woa); accept-encoding = (gzip, deflate); host
= (localhost:53129); accept-language = (en-us); connection = (keep-
alive); } content-length=0 cookies=null userInfo=null>) method=GET
uri=/cgi-bin/WebObjects/TestDirectActionSession.woa/wa/test?
wosid=3m9VMHuhZCAZQSKXcPmjtw defaultFormValueEncoding=ISO8859_1
formValueEncodingDetectionEnabled=NO formValueEncoding=ISO8859_1
formValues={wosid = ("3m9VMHuhZCAZQSKXcPmjtw"); } >
To recover from this:
public class DirectAction extends WODirectAction {
<...>
public someDirectAction() {
String wosid;
int index;
Session session;
wosid = getSessionIDForRequest( request() );
index = wosid.indexOf( "?" );
if ( index >= 0 ) {
wosid = wosid.substring( 0, index );
}
session = Application.application().restoreSessionWithID
( wosid, context() );
}
<...>
}
Better yet, if you're simply wanting an image as a hyperlink - create
a reusable component that _does not_ utilise ismap. Then it'll work
as expected. See WXActiveImage (/Developer/Examples/JavaWebObjects/
Frameworks/WOComponentElements)
with regards,
--
LD
_______________________________________________
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