@Produces
@Param
public <V> ParamValue<V> produce(InjectionPoint injectionPoint) {
// @Param is the annotation on the injection point that holds all data for this request parameter
Param requestParameter = getQualifier(injectionPoint, Param.class);
FacesContext context = FacesContext.getCurrentInstance();
UIComponent component = context.getViewRoot();
String label = getLabel(requestParameter, injectionPoint);
// TODO: Save/restore existing potentially existing label?
component.getAttributes().put("label", label);
// Get raw submitted value from the request
String submittedValue = getRequestParameter(context, getName(requestParameter, injectionPoint));
Object convertedValue = null;
boolean valid = true;
try {
// Convert the submitted value
Converter converter = getConverter(requestParameter, getTargetType(injectionPoint));
if (converter != null) {
convertedValue = converter.getAsObject(context, component, submittedValue);
} else {
convertedValue = submittedValue;
}
// Check for required
if (requestParameter.required() && isEmpty(convertedValue)) {
addRequiredMessage(context, component, label, submittedValue, getRequiredMessage(requestParameter));
}
// Validate the converted value