aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatti Tahvonen <matti.tahvonen@itmill.com>2007-06-08 11:39:29 +0000
committerMatti Tahvonen <matti.tahvonen@itmill.com>2007-06-08 11:39:29 +0000
commit863e88ad5f68b4d8972c42d6272d6963df9b0916 (patch)
treea183d377177792e12823cdd592d19a0c188b97cf /src
parent2cadb1c068e153297ed2404bf4442fb34c87d94b (diff)
downloadvaadin-framework-863e88ad5f68b4d8972c42d6272d6963df9b0916.tar.gz
vaadin-framework-863e88ad5f68b4d8972c42d6272d6963df9b0916.zip
fixes to variable sending, textfield and paint target
svn changeset:1655/svn branch:trunk
Diffstat (limited to 'src')
-rwxr-xr-xsrc/com/itmill/toolkit/terminal/gwt/client/Client.java2
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/TkTextField.java52
-rw-r--r--src/com/itmill/toolkit/terminal/web/AjaxJsonPaintTarget.java6
3 files changed, 37 insertions, 23 deletions
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/Client.java b/src/com/itmill/toolkit/terminal/gwt/client/Client.java
index 2c1f0b4303..4be56306d3 100755
--- a/src/com/itmill/toolkit/terminal/gwt/client/Client.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/Client.java
@@ -104,6 +104,7 @@ public class Client implements EntryPoint {
Date start = new Date();
try{
+ console.log(response.getText().substring(3) + "}");
JSONValue json = JSONParser
.parse(response.getText().substring(3) + "}");
// Process changes
@@ -187,6 +188,7 @@ public class Client implements EntryPoint {
req.append(pendingVariables.get(i++));
req.append("=");
req.append(pendingVariables.get(i));
+ req.append("&");
}
pendingVariables.clear();
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/TkTextField.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/TkTextField.java
index e31f25a437..6dd9f5f4bd 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/TkTextField.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/TkTextField.java
@@ -1,9 +1,11 @@
package com.itmill.toolkit.terminal.gwt.client.ui;
+import com.google.gwt.user.client.ui.ChangeListener;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.client.ui.TextBox;
+import com.google.gwt.user.client.ui.TextBoxBase;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.itmill.toolkit.terminal.gwt.client.Client;
@@ -11,17 +13,21 @@ import com.itmill.toolkit.terminal.gwt.client.Paintable;
import com.itmill.toolkit.terminal.gwt.client.UIDL;
public class TkTextField extends Composite implements
- Paintable {
+ Paintable, ChangeListener {
String id;
Client client;
- Widget field;
+ TextBoxBase field;
Label caption = new Label();
private VerticalPanel p;
+ private boolean multiline = false;
+
+ private boolean immediate = false;
+
public TkTextField() {
p = new VerticalPanel();
p.add(caption);
@@ -31,31 +37,35 @@ public class TkTextField extends Composite implements
public void updateFromUIDL(UIDL uidl, Client client) {
this.client = client;
id = uidl.getId();
+ if(uidl.hasAttribute("immediate") && uidl.getBooleanAttribute("immediate"))
+ immediate = true;
if(uidl.hasAttribute("caption"))
caption.setText(uidl.getStringAttribute("caption"));
else
caption.setVisible(false);
- if(uidl.hasAttribute("rows")) {
- // TODO textarea
- TextArea ta = new TextArea();
- field = ta;
- if(uidl.hasAttribute("cols"))
- ta.setWidth(uidl.getStringAttribute("cols")+"em");
- ta.setHeight(uidl.getStringAttribute("height")+"em");
-
- } else {
- // one line text field
- TextBox tb = new TextBox();
- field = tb;
- if(uidl.hasAttribute("cols"))
- tb.setWidth(uidl.getStringAttribute("cols")+"em");
+ if(field != null && (uidl.hasAttribute("rows") && !multiline )) {
+ // field type has changed
+ p.remove(p.getWidgetIndex(field));
}
- p.add(field);
+ if(field == null) {
+ if(uidl.hasAttribute("rows")) {
+ field = new TextArea();
+ multiline = true;
+ } else {
+ field = new TextBox();
+ }
+ p.add(field);
+ }
+ if(multiline)
+ field.setHeight(uidl.getStringAttribute("height")+"em");
+ if(uidl.hasAttribute("cols"))
+ field.setWidth(uidl.getStringAttribute("cols")+"em");
+
+ field.addChangeListener(this);
+
}
- public void onClick(Widget sender) {
- if (id == null || client == null)
- return;
- client.updateVariable(id, "state", true, true);
+ public void onChange(Widget sender) {
+ client.updateVariable(id, "text", field.getText() , immediate);
}
}
diff --git a/src/com/itmill/toolkit/terminal/web/AjaxJsonPaintTarget.java b/src/com/itmill/toolkit/terminal/web/AjaxJsonPaintTarget.java
index 073636d76c..6c7b520f01 100644
--- a/src/com/itmill/toolkit/terminal/web/AjaxJsonPaintTarget.java
+++ b/src/com/itmill/toolkit/terminal/web/AjaxJsonPaintTarget.java
@@ -164,7 +164,6 @@ public class AjaxJsonPaintTarget implements PaintTarget, AjaxPaintTarget {
if(tag != null) {
openJsonTags.push(tag);
}
-
// Checks tagName and attributes here
mOpenTags.push(tagName);
@@ -211,7 +210,10 @@ public class AjaxJsonPaintTarget implements PaintTarget, AjaxPaintTarget {
tag = parent;
} else {
- this.uidlBuffer.print(tag.getJSON());
+ changes++;
+ this.uidlBuffer.print(
+ ( (changes > 1) ? "," : "") +
+ tag.getJSON());
tag = null;
}
}