private void renderNameField(List form, String fieldName, DCInput dcInput, Metadatum[] dcValues, boolean readonly) throws WingException
{
// The name field is a composite field containing two text fields, one
// for first name the other for last name.
Composite fullName = form.addItem().addComposite(fieldName, "submit-name");
Text lastName = fullName.addText(fieldName+"_last");
Text firstName = fullName.addText(fieldName+"_first");
// Setup the full name
fullName.setLabel(dcInput.getLabel());
fullName.setHelp(cleanHints(dcInput.getHints()));
if (dcInput.isRequired())
{
fullName.setRequired();
}
if (isFieldInError(fieldName))
{
if (dcInput.getWarning() != null && dcInput.getWarning().length() > 0)
{
fullName.addError(dcInput.getWarning());
}
else
{
fullName.addError(T_required_field);
}
}
if (dcInput.isRepeatable() && !readonly)
{
fullName.enableAddOperation();
}
if ((dcInput.isRepeatable() || dcValues.length > 1) && !readonly)
{
fullName.enableDeleteOperation();
}
String fieldKey = MetadataAuthorityManager.makeFieldKey(dcInput.getSchema(), dcInput.getElement(), dcInput.getQualifier());
boolean isAuthorityControlled = MetadataAuthorityManager.getManager().isAuthorityControlled(fieldKey);
if (isAuthorityControlled)
{
fullName.setAuthorityControlled();
fullName.setAuthorityRequired(MetadataAuthorityManager.getManager().isAuthorityRequired(fieldKey));
}
if (ChoiceAuthorityManager.getManager().isChoicesConfigured(fieldKey))
{
fullName.setChoices(fieldKey);
fullName.setChoicesPresentation(ChoiceAuthorityManager.getManager().getPresentation(fieldKey));
fullName.setChoicesClosed(ChoiceAuthorityManager.getManager().isClosed(fieldKey));
}
// Setup the first and last name
lastName.setLabel(T_last_name_help);
firstName.setLabel(T_first_name_help);
if (readonly)
{
lastName.setDisabled();
firstName.setDisabled();
fullName.setDisabled();
}
// Setup the field's values
if (dcInput.isRepeatable() || dcValues.length > 1)
{
for (Metadatum dcValue : dcValues)
{
DCPersonName dpn = new DCPersonName(dcValue.value);
lastName.addInstance().setValue(dpn.getLastName());
firstName.addInstance().setValue(dpn.getFirstNames());
Instance fi = fullName.addInstance();
fi.setValue(dcValue.value);
if (isAuthorityControlled)
{
if (dcValue.authority == null || dcValue.authority.equals(""))
{
fi.setAuthorityValue("", "blank");
}
else
{
fi.setAuthorityValue(dcValue.authority, Choices.getConfidenceText(dcValue.confidence));
}
}
}
}
else if (dcValues.length == 1)
{
DCPersonName dpn = new DCPersonName(dcValues[0].value);
lastName.setValue(dpn.getLastName());
firstName.setValue(dpn.getFirstNames());
if (isAuthorityControlled)
{
if (dcValues[0].authority == null || dcValues[0].authority.equals(""))
{
lastName.setAuthorityValue("", "blank");