use of org.jivesoftware.smackx.xdata.FormField in project Smack by igniterealtime.
the class SubscribeForm method addField.
private void addField(SubscribeOptionFields nodeField, FormField.Type type) {
String fieldName = nodeField.getFieldName();
if (getField(fieldName) == null) {
FormField field = new FormField(fieldName);
field.setType(type);
addField(field);
}
}
use of org.jivesoftware.smackx.xdata.FormField in project Smack by igniterealtime.
the class SimpleUserSearch method getItemsToSearch.
private String getItemsToSearch() {
StringBuilder buf = new StringBuilder();
if (form == null) {
form = Form.getFormFrom(this);
}
if (form == null) {
return "";
}
for (FormField field : form.getFields()) {
String name = field.getVariable();
String value = getSingleValue(field);
if (value.trim().length() > 0) {
buf.append('<').append(name).append('>').append(value).append("</").append(name).append('>');
}
}
return buf.toString();
}
use of org.jivesoftware.smackx.xdata.FormField in project Smack by igniterealtime.
the class UserSearch method buildDataForm.
private static void buildDataForm(SimpleUserSearch search, String instructions, XmlPullParser parser) throws Exception {
DataForm dataForm = new DataForm(DataForm.Type.form);
boolean done = false;
dataForm.setTitle("User Search");
dataForm.addInstruction(instructions);
while (!done) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG && !parser.getNamespace().equals("jabber:x:data")) {
String name = parser.getName();
FormField field = new FormField(name);
// Handle hard coded values.
if (name.equals("first")) {
field.setLabel("First Name");
} else if (name.equals("last")) {
field.setLabel("Last Name");
} else if (name.equals("email")) {
field.setLabel("Email Address");
} else if (name.equals("nick")) {
field.setLabel("Nickname");
}
field.setType(FormField.Type.text_single);
dataForm.addField(field);
} else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals("query")) {
done = true;
}
} else if (eventType == XmlPullParser.START_TAG && parser.getNamespace().equals("jabber:x:data")) {
PacketParserUtils.addExtensionElement(search, parser);
done = true;
}
}
if (search.getExtension("x", "jabber:x:data") == null) {
search.addExtension(dataForm);
}
}
use of org.jivesoftware.smackx.xdata.FormField in project Smack by igniterealtime.
the class ConfigureForm method toString.
@Override
public String toString() {
StringBuilder result = new StringBuilder(getClass().getName() + " Content [");
for (FormField formField : getFields()) {
result.append('(');
result.append(formField.getVariable());
result.append(':');
StringBuilder valuesBuilder = new StringBuilder();
for (String value : formField.getValues()) {
if (valuesBuilder.length() > 0)
result.append(',');
valuesBuilder.append(value);
}
if (valuesBuilder.length() == 0)
valuesBuilder.append("NOT SET");
result.append(valuesBuilder);
result.append(')');
}
result.append(']');
return result.toString();
}
use of org.jivesoftware.smackx.xdata.FormField in project Smack by igniterealtime.
the class MamManager method getNewMamForm.
private static DataForm getNewMamForm() {
FormField field = new FormField(FormField.FORM_TYPE);
field.setType(FormField.Type.hidden);
field.addValue(MamElements.NAMESPACE);
DataForm form = new DataForm(DataForm.Type.submit);
form.addField(field);
return form;
}
Aggregations