Java Code Examples for org.jivesoftware.smackx.xdata.FormField#isRequired()

The following examples show how to use org.jivesoftware.smackx.xdata.FormField#isRequired() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FillableForm.java    From Smack with Apache License 2.0 6 votes vote down vote up
public FillableForm(DataForm dataForm) {
    super(dataForm);
    if (dataForm.getType() != DataForm.Type.form) {
        throw new IllegalArgumentException();
    }

    Set<String> requiredFields = new HashSet<>();
    for (FormField formField : dataForm.getFields()) {
        if (formField.isRequired()) {
            String fieldName = formField.getFieldName();
            requiredFields.add(fieldName);
            missingRequiredFields.add(fieldName);
        }
    }
    this.requiredFields = Collections.unmodifiableSet(requiredFields);
}
 
Example 2
Source File: WorkgroupManager.java    From Spark with Apache License 2.0 5 votes vote down vote up
private static boolean validateForm(JDialog parent, Form workgroupForm, Form form) {
    for ( final FormField field : form.getFields()) {
        if (field.isRequired() && field.getValues().isEmpty()) {
            String variable = field.getVariable();
            String elementName = workgroupForm.getField(variable).getLabel();
            UIManager.put("OptionPane.okButtonText", Res.getString("ok"));
            JOptionPane.showMessageDialog(parent, variable + " is required to complete the form.", "Incomplete Form", JOptionPane.ERROR_MESSAGE);
            return false;
        }
    }

    return true;
}