Smack 4.4.x: How to properly create Leaf node

Hi,

I’m updating Smack libraries from version 4.3.x to 4.4.6 and I’m now having troubles to properly update code to create LeafNode on PubSub, or better say, prepare ConfigureForm for new LeafNode.
In version 4.3.x I used this code to create ConfigureForm:

ConfigureForm leafNodeForm = new ConfigureForm(DataForm.Type.submit);
leafNodeForm.setAccessModel(AccessModel.presence);
leafNodeForm.setDeliverPayloads(true);
leafNodeForm.setPersistentItems(true);
leafNodeForm.setPublishModel(PublishModel.publishers);
leafNodeForm.setMaxItems(1);

Now, with Smack version 4.4.x this doesn’t seem to be working. I figured out that now to create an LeafNode, a FillableConfigureForm has to be used, but I’m having trouble to initiate new one, or better say, I haven’t found the way yet how to properly initiate it because its constructor is private. One way I tried is to create new ConfigureForm with ‘submit’ type and then from that ConfigureForm instance to get FillableConfigureForm through getFillableForm() function, but this way a form with any type other than ‘form’ cannot be created, so I’m a bit stuck now.
Can someone help me with my issue and show me how can I properly create new LeafNode?

Thanks in advance!

Anyone has any idea?

Try something like this:

DomainBareJid pubSubService = PubSubManager.getPubSubService(connection);
PubSubManager pubSubManager = PubSubManager.getInstanceFor(connection, pubSubService);
ConfigureForm defaultConfiguration = pubSubManager.getDefaultConfiguration();
FillableConfigureForm config = defaultConfiguration.getFillableForm();
config.setAccessModel(AccessModel.presence);
config.setDeliverPayloads(true);
config.setPersistentItems(true);
config.setPublishModel(PublishModel.publishers);
pubSubManager.createNode("name-of-the-node", config);

Thank you very much for your help! This one works!

This topic was automatically closed 62 days after the last reply. New replies are no longer allowed.