use of com.willshex.blogwt.client.part.form.TextAreaPart 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.client.part.form.TextAreaPart in project blogwt by billy1380.
the class FormPart method addFieldWithLine.
/**
* @param line
*/
public void addFieldWithLine(String line) {
if (line.length() > 0) {
ConfigLine config = parseConfigLine(line);
boolean autofocus = pnlFields.getWidgetCount() == 0;
switch(FieldTypeType.fromString(config.type)) {
case FieldTypeTypeText:
TextBoxPart textBox = new TextBoxPart();
textBox.elName.setInnerHTML(config.name);
UiHelper.addPlaceholder(textBox.txtValue, config.name);
textBox.txtValue.setValue(config.defaultValue);
pnlFields.add(textBox);
if (autofocus) {
UiHelper.autoFocus(textBox.txtValue);
}
break;
case FieldTypeTypeLongText:
TextAreaPart longText = new TextAreaPart();
longText.elName.setInnerHTML(config.name);
UiHelper.addPlaceholder(longText.txtValue, config.name);
longText.txtValue.setValue(config.defaultValue);
longText.txtValue.setVisibleLines(4);
pnlFields.add(longText);
if (autofocus) {
UiHelper.autoFocus(longText.txtValue);
}
break;
case FieldTypeTypeSingleOption:
ListBoxPart listBox = new ListBoxPart();
listBox.elName.setInnerHTML(config.name);
UiHelper.addPlaceholder(listBox.lbxValue, config.name);
if (config.allowedValues != null) {
int size = config.allowedValues.size();
String value;
for (int i = 0; i < size; i++) {
value = config.allowedValues.get(i);
listBox.lbxValue.addItem(value, value);
if (value.equals(config.defaultValue)) {
listBox.lbxValue.setSelectedIndex(i);
}
}
}
pnlFields.add(listBox);
if (autofocus) {
UiHelper.autoFocus(listBox.lbxValue);
}
break;
case FieldTypeTypeCaptcha:
if (reCaptcha == null) {
reCaptcha = new ReCaptchaPart();
reCaptcha.setApiKey(config.parameters.get(RECAPTCH_API_KEY));
} else {
reCaptcha.removeFromParent();
reCaptcha.reset();
}
pnlFields.add(reCaptcha);
break;
}
}
}
Aggregations