I’'m currently using smack 1.4.0 and have been following the documentation on creating a MUC conference room.
The code (below) found in the documentation under “MUC-Creating a room” throws an exception on “submitForm.setAnswer(field.getVariable(), values);”:
java.lang.IllegalArgumentException: This field only accept list of values.
I’'ve tried changing what type of variable is set in the setAnswer, but I have been unable to fix the problem.
Any help would be appreciated
// Create a MultiUserChat using an XMPPConnection for a room
MultiUserChat muc = new MultiUserChat(conn1, "myroom@conference.jabber.org");
// Create the room
muc.create(“testbot”);
// Get the the room’'s configuration form
Form form = muc.getConfigurationForm();
// Create a new form to submit based on the original form
Form submitForm = form.createAnswerForm();
// Add default answers to the form to submit
for (Iterator fields = form.getFields(); fields.hasNext() {
FormField field = (FormField) fields.next();
if (!FormField.TYPE_HIDDEN.equals(field.getType()) && field.getVariable() != null) {
// Add the field values to a List
List values = new ArrayList();
for (Iterator it = field.getValues(); it.hasNext() {
values.add((String) it.next());
}
// Sets the new answer to the form to submit
submitForm.setAnswer(field.getVariable(), values);
}
}
// Send the completed form (with default values) to the server to configure the room
muc.sendConfigurationForm(submitForm);