powered by Jive Software

Forms without FORM_TYPE

To start with, thanks for the quick work on SMACK-902 regarding the DataForm reported types.

In our chat client we heavily rely on data forms, and have an implementation of XEP-0346: Form Discovery and Publishing which has been in use for a number of years now.

This feature allows our administrators to create and publish forms, which can then be filled out by users and submitted. These forms have to adhere to XEP-0004, and may use some XEP’s related to additional form field types (for example: XEP-350: Data Forms Geolocation Element). The forms do not have a FORM_TYPE field set.

We are now trying to migrate from Smack 4.3.4 to 4.4.0, but are having a lot of problems with the new DataForm’s API in 4.4.0. In 4.4.0 the use of a FORM_TYPE seems to be mandatory. Even DataForms that do not have the FORM_TYPE field set lookup field types in the FormFieldRegistry, and DataForms without a FORM_TYPE are registered in the FormFieldRegistry.

This causes all sorts of problems for us, because forms are registered, and their registered field types are imposed to other forms that do not have a FORM_TYPE set. In many cases a plain DataForm without a FORM_TYPE will not even get successfully parsed by the DataFormProvider.

I would like to request a change to the Data Form API so that it treats forms without a FORM_TYPE set as unregistered forms: not registered in the FormFieldRegistry, and the FormFieldRegistry is not uses when deciding upon their type.
This would result in the following logic:

If no FORM_TYPE field is set, the form fields are parsed as specified in XEP-0004, and the
field type is determined as follows:

  1. the field type set to the field itself
  2. the field type set in the <reported> section of result forms
  3. the field type default of text-single is used

If a FORM_TYPE field is set, the lookup of form field types looks like this:

  1. the field type set to the field itself
  2. the field type set in the <reported> section of result forms
  3. the FormFieldRegistry is checked for a preregistered type of the field for this FORM_TYPE
  4. the field type default of text-single is used

To improve the support for DataForms without a FORM_TYPE, the FilledForm and FillableForm’s
should also be able to handle forms without a FORM_TYPE. The FilledForm and FillableForm subclasses for specific FORM_TYPE’s already use ensureFormType() to make sure the proper FORM_TYPE is set.

These changes would allow us to parse and interact with plain old DataForm’s (without a FORM_TYPE) using the API’s in Smack.

I’ve created a commit which makes these changes (https://github.com/fenuz/Smack/commit/323dfe77408f1f7805c1c49d40bbfe930b43e49b). I would much appreciate it if you could discuss our problem and our proposed solution.

Thank you all your work,
Frank

First, let me say that I see that the changes in Smack 4.4 can cause troubles and that I am open to relax the current assumption that FORM_TYPE and XEP-0068 are ubiquitous in data forms.

This would allow inconsistencies between the field’s declared type and the registry to go unnoticed. Hence I would go for 3. 1. 2. 4, Where there is a verification step if there is a registry entry and an explicitly declared form field type, which ensures that both agree.

Sure, the usual way to discuss proposed changes involves a GitHub pull request.

I’m glad to hear that.

I will modify my branch to add the verification step you mentioned, and submit a pull request. We can then discuss any other required changes there.

Ping :slight_smile:
I am actually holding back the 4.1.1 release waiting for this. Let me know if you need more time.

I’ve created

Please let me know if this helps. Thanks.

Thanks, I did not get around to it. I’ll have a look today!

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