XFFormElementImpl formElement
= (XFFormElementImpl) pageContext.getCurrentElement();
XFFormAttributes formAttributes = formElement.getProtocolAttributes();
// Get the enclosing form element's descriptor.
FormDescriptor formDescriptor = formElement.getFormDescriptor();
// Add a reference back to the form attributes.
pattributes.setFormAttributes(formAttributes);
pattributes.setFormData(formAttributes.getFormData());
// Set the name.
String name = attributes.getName();
pattributes.setName(name);
// Set the value.
String value = attributes.getValue();
pattributes.setValue(value);
PolicyReferenceResolver resolver =
pageContext.getPolicyReferenceResolver();
// Set the client variable name
TextAssetReference reference = resolver.resolveQuotedTextExpression(
attributes.getClientVariableName());
String clientVariableName = getPlainText(reference);
// One of value and clientVariableName must be specified.
if (value == null && clientVariableName == null) {
throw new PAPIException(exceptionLocalizer.format(
"xfimplicit-value-or-client-variable-name"));
}
pattributes.setClientVariableName(clientVariableName);
// Create the field descriptor.
FieldDescriptor fieldDescriptor = new FieldDescriptor();
fieldDescriptor.setName(name);
fieldDescriptor.setType(ImplicitFieldType.getSingleton());
fieldDescriptor.setInitialValue(value);
// Add a reference to the field descriptor into the attributes.
pattributes.setFieldDescriptor(fieldDescriptor);
// Add the attributes to the list.
formAttributes.addField(pattributes);
// Add the field descriptor to the list.
formDescriptor.addField(fieldDescriptor);
return PROCESS_ELEMENT_BODY;
}