Hi
Using Smack 3.2.1.
I want to create a node on a pub sub service, and then create child nodes of that node. I am trying this:
private void createNodes() {
String leafNodeName = null;
String rootNodeName = null;
ArrayList children = new ArrayList();
try {
rootNodeName = properties.getProperty(“rootNode”);
ConfigureForm form = new ConfigureForm(FormType.submit);
Iterator iterator = getPubSubNodeNames().iterator();
while (iterator.hasNext()) {
leafNodeName = iterator.next();
children.add(leafNodeName);
}
form.setChildren(children);
Node node = (Node) pubSubManager.createNode(rootNodeName, form);
When I try this:
form.setChildren(children);
I get to Form.java here:
public void setAnswer(String variable, List values) {
if (!isSubmitType()) {
throw new IllegalStateException("Cannot set an answer if the form is not of type " +
““submit””);
}
FormField field = getField(variable);
if (field != null) {
// Check that the field can accept a collection of values
if (!FormField.TYPE_JID_MULTI.equals(field.getType())
&& !FormField.TYPE_LIST_MULTI.equals(field.getType())
&& !FormField.TYPE_LIST_SINGLE.equals(field.getType())
&& !FormField.TYPE_HIDDEN.equals(field.getType())) {
throw new IllegalArgumentException(“This field only accept list of values.”);
And the IllegalArgumentException is thrown.
The debug values are:
values ArrayList (id=37)
[exampleNodeAAAAA]
field FormField (id=59)
description null
label null
options ArrayList (id=62)
required false
type “text-multi” (id=63)
values ArrayList (id=64)
variable “pubsub#children” (id=65)
I have looked through the test code for an example of what I should be doing, but I don’t see one.
Any ideas please?
Many thanks
Nathan