powered by Jive Software

FormField convenience construction


#1

In Smack 4.3, it’s rather cumbersome to create a FormField and populate it with a value (typical use case):

FormField formField = new FormField(FORM_FIELD_START);
formField.addValue(start);
formFields.put(formField.getVariable(), formField);

FormField endFormField = formFields.get(FORM_FIELD_END);
....

It would be awesome to have either FormField.addValue() return this, or have a default constructor for a single-value field (there are three different methods to add values, but I’m primarily interested in the string variant):

// option a
formFields.addField(new Field(FORM_FIELD_START).addValue(start));

// option b
formFields.addField(new Field(FORM_FIELD_START, start));

Bonus points for a dedicated helper method to create the hidden FORM_TYPE value.


#2

Sounds sensible. :slight_smile:

As always patches are welcome (but please talk to be first if you want them to be not based on the master branch).


closed #3

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