Re: Returning results from HTTPConnection request...
Re: Returning results from HTTPConnection request...
- Subject: Re: Returning results from HTTPConnection request...
- From: Chuck Hill <email@hidden>
- Date: Wed, 14 Dec 2005 11:39:39 -0800
Hi,
On Dec 12, 2005, at 12:24 PM, Nathan Walker wrote:
I guess I was looking to see if anybody had any innovative ideas on
this concept. I guess I could have the Flash constantly looping
through posting requests to the server and checking things, (Maybe
have a DirectAction that returned an XML response telling the Flash
animation how much cash had been inserted. That way, there is no
MetaRefresh and the app seems to be sitting there and active
without having to Refresh every 3 seconds or so to check variables
and such.
But it is still cycling back to the server.
That seems bloated though, because essentially the Flash animation
would be posting a request every 3 seconds checking for the
response value avoiding the metarefresh. Maybe this is where AJAX
should be used ?
Then AJAX would be doing the same sort of server polling, no?
It seems to me this sort of thing is needed a lot. Surely not
everybody out there is using WOMetaRefresh for this are they ??
I don't see there is much of an option. Something has to check
unless your app has a direct connection to each client.
Chuck
On Dec 12, 2005, at 1:01 PM, Chuck Hill wrote:
Now I am more confused. :-)
On Dec 11, 2005, at 10:31 PM, Nathan Walker wrote:
Here's the complete class: Basically, it initiates a JNI method
that could take awhile and waits for a user to enter in some
Cash, once the cash has met the expected value (all handled in
the C class) then it returns and I'd like to return the results
to the current browser.
How? HTTP is a pull not a push technology. You can't force the
browser to show something it has not requested.
I'm initiating this in a Thread to avoid using a WOMetaRefresh
page, I just don't like using MetaRefresh...
I don't know of much else that can simulate push technology in http.
And so the user sees a repeating flash animation until all Cash
is inserted and then a response is generated and they are
redirected to a ReviewDetails page.
A flash animation that re-implemented a meta-refresh could, but I
don't see the advantage. How does the Flash know when a response
is generated? It could return the generated response to the browser.
Chuck
public class PayReader {
public int expectedValue = 1;
public int cashInserted = 0;
public native int matrixCashRead(int expectedValue);
static {
System.loadLibrary("MatrixCash");
}
public WOResponse CashRead(PayReader pr,Application
myApp,Session mySess){
pr.cashInserted = pr.matrixCashRead(pr.expectedValue);
System.out.println("Total Cash Inserted: $" + pr.cashInserted);
System.out.println("----");
String buildURL = "http://" + myApp.host() + ":" + myApp.port()
+ "/cgi-bin/WebObjects/BSSKIOSK.woa/wa/CashRead?wosid=" +
mySess.sessionID() +
"&completed=1&totalcash=" + pr.cashInserted;
WORequest requestFinish = new WORequest("GET",buildURL,"HTTP/
1.1",null,null,null);
WOHTTPConnection connectTo = new WOHTTPConnection(myApp.host
(),myApp.port().intValue());
connectTo.sendRequest(requestFinish);
WOResponse response = connectTo.readResponse();
return response;
}
public Number addCash(String value, Number currentValue){
return new Integer(Integer.parseInt(value) +
currentValue.intValue());
}
}
Here's the thread I'm using to call open this class:
class PaymentThread extends Thread {
Session sess = (Session)session();
public PaymentThread(String type) {
super(type);
}
public void run() {
PayReader pr = new PayReader();
pr.CashRead(pr,(Application)WOApplication.application(),sess);
}
}
Thanks,
Nathan
On Dec 12, 2005, at 1:03 AM, Chuck Hill wrote:
On Dec 11, 2005, at 9:44 PM, Nathan Walker wrote:
I am overlooking something it seems or maybe it's just been a
long day but I'm just trying to get the response from the
HTTPConnection request and return that in the current browser
window. Below is the code I've tried:
String buildURL = "http://" + myApp.host() + ":" + myApp.port()
+ "/cgi-bin/WebObjects/BSSKIOSK.woa/wa/CashRead?wosid=" +
mySess.sessionID() +
"&completed=1&totalcash=" + pr.cashInserted;
WORequest requestFinish = new WORequest("POST",buildURL,"HTTP/
1.1",null,null,null);
WOHTTPConnection connectTo = new WOHTTPConnection(myApp.host
(),myApp.port().intValue());
connectTo.sendRequest(requestFinish);
WOResponse response = connectTo.readResponse();
return response;
You can see that the WOHTTPConnection is Posting to a Direct
Action, I'd like to return the results from that Direct Action
to the browser. This is being done is a private Thread and
that's why I need to do it this way. Can I return the results
into the current browser window ? It seems to of course just
return the WOResponse object which doesn't generate a response
in the current browser window ??
Where is this code? In some action method called during
invokeAction? You would need to hang onto the response and then
in appendToResponse do
response.setContent(responseFromDA.content());
We probably need more information to answer properly.
Chuck
--
Coming in 2006 - an introduction to web applications using
WebObjects and Xcode http://www.global-village.net/wointro
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
--
Coming in 2006 - an introduction to web applications using
WebObjects and Xcode http://www.global-village.net/wointro
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
--
Coming in 2006 - an introduction to web applications using WebObjects
and Xcode http://www.global-village.net/wointro
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