Modified:
/trunk/src/com/google/minijoe/html/InputWidget.java
/trunk/src/com/google/minijoe/samples/browser/HtmlBrowser.java
/trunk/src/com/google/minijoe/samples/browser/ResourceRequester.java
=======================================
--- /trunk/src/com/google/minijoe/html/InputWidget.java Sun Feb 14 18:05:31
2010
+++ /trunk/src/com/google/minijoe/html/InputWidget.java Mon Feb 22 16:37:29
2010
@@ -323,7 +323,7 @@
return true;
case Skin.INPUT_TYPE_SUBMIT:
- submit();
+ submit(element.getAttributeValue("value"));
return true;
}
}
@@ -391,9 +391,7 @@
}
if (value != null && key != null) {
- if (sb.length() != 0) {
- sb.append('&');
- }
+ sb.append('&');
sb.append(Util.encodeURL(key));
sb.append('=');
sb.append(Util.encodeURL(value));
@@ -409,9 +407,12 @@
/**
* Submits a form.
*/
- private void submit() {
+ private void submit(String submitValue) {
Element form = findForm();
- StringBuffer buf = new StringBuffer("");
+ StringBuffer buf = new StringBuffer("submit=");
+ if (submitValue != null) {
+ buf.append(Util.encodeURL(submitValue));
+ }
collectFormData(form, buf);
String url = document.getAbsoluteUrl(form.getAttributeValue("action"));
=======================================
--- /trunk/src/com/google/minijoe/samples/browser/HtmlBrowser.java Fri Feb
19 16:14:29 2010
+++ /trunk/src/com/google/minijoe/samples/browser/HtmlBrowser.java Mon Feb
22 16:37:29 2010
@@ -229,6 +229,7 @@
String exKey = exCookie[COOKIE_NAME];
if (key.equals(exKey) && domain.equals(exDomain) &&
path.equals(exPath)) {
+ // System.out.println("removing old cookie index " + i);
cookies.removeElementAt(i);
}
}
@@ -249,6 +250,11 @@
}
}
cookie[COOKIE_EXPIRES] = "" + expiresMillis;
+
+ //for (int i = 0; i < cookie.length; i++) {
+ // System.out.println("setcookie[" + i +"]: " + cookie[i]);
+ //}
+
cookies.addElement(cookie);
}
=======================================
--- /trunk/src/com/google/minijoe/samples/browser/ResourceRequester.java
Mon Feb 15 16:34:01 2010
+++ /trunk/src/com/google/minijoe/samples/browser/ResourceRequester.java
Mon Feb 22 16:37:29 2010
@@ -70,6 +70,9 @@
int cut = url.indexOf('#');
+// System.out.println("");
+// System.out.println("Requesting: " + url);
+
StreamConnection con = (StreamConnection) Connector.open(
cut == -1 ? url : url.substring(0, cut),
post ? Connector.READ_WRITE : Connector.READ);
@@ -83,6 +86,7 @@
HttpConnection httpCon = (HttpConnection) con;
if (post) {
httpCon.setRequestMethod("POST");
+
httpCon.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
}
httpCon.setRequestProperty("User-Agent", browser.userAgent);
httpCon.setRequestProperty("X-Screen-Width", ""+screen.getWidth());
@@ -91,6 +95,7 @@
String cookie = browser.getCookies(url);
if (cookie != null) {
+// System.out.println("Setting Cookie: " + cookie);
httpCon.setRequestProperty("Cookie", cookie);
}
@@ -98,8 +103,10 @@
OutputStream os = httpCon.openOutputStream();
os.write(requestData);
os.close();
+// System.out.println("Postdata\n" + new String(requestData));
}
+// System.out.println("receiving:");
contentLength = (int) httpCon.getLength();
int headerIndex = 0;
while (true){
@@ -108,7 +115,8 @@
break;
}
name = name.toLowerCase();
-
+// System.out.println(name + ": " +
httpCon.getHeaderField(headerIndex));
+
if ("content-type".equals(name)) {
String value = httpCon.getHeaderField(headerIndex);
if (value.indexOf("vnd.sun.j2me.app-descriptor") != -1) {
@@ -122,7 +130,7 @@
} else if ("set-cookie".equals(name)) {
String cName = "";
String cValue = "";
- String cHost = "";
+ String cHost = httpCon.getHost();
String cPath = "";
String cExpires = null;
String cSecure = null;
@@ -158,11 +166,11 @@
}
int responseCode = httpCon.getResponseCode();
-
+// System.out.println("Response Code: " +
httpCon.getResponseCode());
if (responseCode >= 300 && responseCode <= 310) {
String location = httpCon.getHeaderField("Location");
if (location != null) {
- System.out.println("Redirecting to: " + location);
+// System.out.println("Redirecting to: " + location);
screen.htmlWidget.setUrl(location);
browser.requestResource(screen.htmlWidget, method, location,
type, requestData);