use of com.willshex.blogwt.shared.api.datatype.Form in project blogwt by billy1380.
the class FormPart method onFormSubmit.
@UiHandler("frmForm")
void onFormSubmit(SubmitEvent se) {
if (isValid()) {
loading();
Form form = new Form();
form.name = name;
// add fields to form
final int count = pnlFields.getWidgetCount();
Widget current;
Field field;
for (int i = 0; i < count; i++) {
current = pnlFields.getWidget(i);
field = null;
if (current instanceof FormField) {
field = new Field().name(((FormField) current).name()).value(((FormField) current).value());
if (form.fields == null) {
form.fields = new ArrayList<Field>();
}
form.fields.add(field);
if (current instanceof TextBoxPart) {
field.type(FieldTypeType.FieldTypeTypeText);
} else if (current instanceof TextAreaPart) {
field.type(FieldTypeType.FieldTypeTypeLongText);
} else if (current instanceof ListBoxPart) {
field.type(FieldTypeType.FieldTypeTypeSingleOption);
} else if (current instanceof ReCaptchaPart) {
field.type(FieldTypeType.FieldTypeTypeCaptcha);
}
}
}
FormController.get().submitForm(form);
}
se.cancel();
}
use of com.willshex.blogwt.shared.api.datatype.Form in project blogwt by billy1380.
the class SubmitFormRequest method fromJson.
@Override
public void fromJson(JsonObject jsonObject) {
super.fromJson(jsonObject);
if (jsonObject.has("form")) {
JsonElement jsonForm = jsonObject.get("form");
if (jsonForm != null) {
form = new Form();
form.fromJson(jsonForm.getAsJsonObject());
}
}
}
Aggregations