FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

deal with empty submit entries · dimr/processing@a62238a · GitHub

Repository navigation

Commit a62238a

Browse files
committed
deal with empty submit entries
1 parent 42a5a10 commit a62238a

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

‎app/src/processing/app/ui/WebFrame.java‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,17 @@ public void actionPerformed(ActionEvent e) {
9898
public void hyperlinkUpdate(HyperlinkEvent e) {
9999
//System.out.println(e);
100100
if (e instanceof FormSubmitEvent) {
101-
//System.out.println("got submit event");
102101
String result = ((FormSubmitEvent) e).getData();
103102
StringDict dict = new StringDict();
104-
String[] pairs = result.split("&");
105-
for (String pair : pairs) {
106-
String[] pieces = pair.split("=");
107-
String attr = PApplet.urlDecode(pieces[0]);
108-
String valu = PApplet.urlDecode(pieces[1]);
109-
dict.set(attr, valu);
103+
if (result.trim().length() != 0) {
104+
String[] pairs = result.split("&");
105+
for (String pair : pairs) {
106+
System.out.println("pair is " + pair);
107+
String[] pieces = pair.split("=");
108+
String attr = PApplet.urlDecode(pieces[0]);
109+
String valu = PApplet.urlDecode(pieces[1]);
110+
dict.set(attr, valu);
111+
}
110112
}
111113
//dict.print();
112114
handleSubmit(dict);
@@ -159,7 +161,7 @@ public void handleClose() {
159161
/**
160162
* Override this to do something interesting when a form is submitted.
161163
* To keep things simple, this doesn't allow for multiple params with the
162-
* same name.
164+
* same name. If no params submitted, the Dict will be empty (not null).
163165
*/
164166
public void handleSubmit(StringDict dict) {
165167
}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL