-
Notifications
You must be signed in to change notification settings - Fork 5
/
HtmlInputText.java
52 lines (40 loc) · 1.33 KB
/
HtmlInputText.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package org.genericsystem.reactor.htmltag;
import org.genericsystem.reactor.modelproperties.ActionDefaults;
import java.util.function.Consumer;
import org.genericsystem.reactor.Context;
import org.genericsystem.reactor.HtmlDomNode;
import org.genericsystem.reactor.Tag;
import org.genericsystem.reactor.gscomponents.GSTagImpl;
import io.vertx.core.json.JsonObject;
import javafx.beans.property.Property;
public class HtmlInputText extends GSTagImpl implements ActionDefaults {
public HtmlInputText() {
}
public HtmlInputText(Tag parent) {
super(parent);
}
@Override
public String getTag() {
return "input";
}
@Override
public HtmlDomNode createNode(HtmlDomNode parent, Context modelContext) {
return new HtmlDomNode(parent, modelContext, this) {
@Override
public JsonObject fillJson(JsonObject jsonObj) {
super.fillJson(jsonObj);
return jsonObj.put("type", "text");
}
@Override
public void handleMessage(JsonObject json) {
if (ADD.equals(json.getString(MSG_TYPE))) {
Property<Consumer<Object>> action = ((ActionDefaults) getTag()).getActionProperty(getModelContext());
if (action != null)
action.getValue().accept(new Object());
}
if (UPDATE.equals(json.getString(MSG_TYPE)))
getTag().getDomNodeAttributes(getModelContext()).put("value", json.getString(TEXT_CONTENT));
}
};
}
}