mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-29 09:42:06 +01:00
Fix documentation wrt FormField and DataForm Type
This commit is contained in:
parent
1bc3e10cff
commit
9d775c8418
2 changed files with 8 additions and 8 deletions
|
@ -22,11 +22,11 @@ entity.
|
||||||
**Usage**
|
**Usage**
|
||||||
|
|
||||||
In order to create a Form to fill out use the _**Form**_'s constructor passing
|
In order to create a Form to fill out use the _**Form**_'s constructor passing
|
||||||
the constant **Form.TYPE_FORM** as the parameter. The next step is to create
|
the constant **DataForm.type.form** as the parameter. The next step is to create
|
||||||
the form fields and add them to the form. In order to create and customize a
|
the form fields and add them to the form. In order to create and customize a
|
||||||
_**FormField**_ use the _**FormField**_'s constructor specifying the variable
|
_**FormField**_ use the _**FormField**_'s constructor specifying the variable
|
||||||
name of the field as the parameter. Then use **setType(String type)** to set
|
name of the field as the parameter. Then use **setType(String type)** to set
|
||||||
the field's type (e.g. FormField.TYPE_HIDDEN, FormField.TYPE_TEXT_SINGLE).
|
the field's type (e.g. FormField.type.hidden, FormField.type.text_single).
|
||||||
Once we have the _**Form**_ instance and the _**FormFields**_ the last step is
|
Once we have the _**Form**_ instance and the _**FormFields**_ the last step is
|
||||||
to send **addField(FormField field)** for each field that we want to add to
|
to send **addField(FormField field)** for each field that we want to add to
|
||||||
the form.
|
the form.
|
||||||
|
@ -41,12 +41,12 @@ In this example we can see how to create and send a form to fill out:
|
||||||
|
|
||||||
```
|
```
|
||||||
// Create a new form to gather data
|
// Create a new form to gather data
|
||||||
Form formToSend = new Form(Form.TYPE_FORM);
|
Form formToSend = new Form(DataForm.type.form);
|
||||||
formToSend.setInstructions(Fill out this form to report your case.\nThe case will be created automatically.");
|
formToSend.setInstructions(Fill out this form to report your case.\nThe case will be created automatically.");
|
||||||
formToSend.setTitle("Case configurations");
|
formToSend.setTitle("Case configurations");
|
||||||
// Add a hidden variable to the form
|
// Add a hidden variable to the form
|
||||||
FormField field = new FormField("hidden_var");
|
FormField field = new FormField("hidden_var");
|
||||||
field.setType(FormField.TYPE_HIDDEN);
|
field.setType(FormField.type.hidden);
|
||||||
field.addValue("Some value for the hidden variable");
|
field.addValue("Some value for the hidden variable");
|
||||||
formToSend.addField(field);
|
formToSend.addField(field);
|
||||||
// Add a fixed variable to the form
|
// Add a fixed variable to the form
|
||||||
|
@ -56,12 +56,12 @@ formToSend.addField(field);
|
||||||
// Add a text-single variable to the form
|
// Add a text-single variable to the form
|
||||||
field = new FormField("name");
|
field = new FormField("name");
|
||||||
field.setLabel("Enter a name for the case");
|
field.setLabel("Enter a name for the case");
|
||||||
field.setType(FormField.TYPE_TEXT_SINGLE);
|
field.setType(FormField.type.text_single);
|
||||||
formToSend.addField(field);
|
formToSend.addField(field);
|
||||||
// Add a text-multi variable to the form
|
// Add a text-multi variable to the form
|
||||||
field = new FormField("description");
|
field = new FormField("description");
|
||||||
field.setLabel("Enter a description");
|
field.setLabel("Enter a description");
|
||||||
field.setType(FormField.TYPE_TEXT_MULTI);
|
field.setType(FormField.type.text_multi);
|
||||||
formToSend.addField(field);
|
formToSend.addField(field);
|
||||||
// Create a chat with "user2@host.com"
|
// Create a chat with "user2@host.com"
|
||||||
Chat chat = conn1.createChat("user2@host.com" );
|
Chat chat = conn1.createChat("user2@host.com" );
|
||||||
|
|
|
@ -59,7 +59,7 @@ muc.create("testbot");
|
||||||
|
|
||||||
// Send an empty room configuration form which indicates that we want
|
// Send an empty room configuration form which indicates that we want
|
||||||
// an instant room
|
// an instant room
|
||||||
muc.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));
|
muc.sendConfigurationForm(new Form(DataForm.Type.submit));
|
||||||
```
|
```
|
||||||
|
|
||||||
In this example we can see how to create a reserved room. The form is
|
In this example we can see how to create a reserved room. The form is
|
||||||
|
@ -82,7 +82,7 @@ Form submitForm = form.createAnswerForm();
|
||||||
// Add default answers to the form to submit
|
// Add default answers to the form to submit
|
||||||
for (Iterator fields = form.getFields(); fields.hasNext();) {
|
for (Iterator fields = form.getFields(); fields.hasNext();) {
|
||||||
FormField field = (FormField) fields.next();
|
FormField field = (FormField) fields.next();
|
||||||
if (!FormField.TYPE_HIDDEN.equals(field.getType()) && field.getVariable() != null) {
|
if (!FormField.type.hidden.equals(field.getType()) && field.getVariable() != null) {
|
||||||
// Sets the default value as the answer
|
// Sets the default value as the answer
|
||||||
submitForm.setDefaultAnswer(field.getVariable());
|
submitForm.setDefaultAnswer(field.getVariable());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue