public static UIInput createInputForDynamicProperty(PropertyDefinitionDynamic propertyDefinitionDynamic,
PropertySimple property, ValueExpression valueExpression, Integer listIndex, boolean isGroupConfig,
boolean configReadOnly, boolean configFullyEditable, boolean prevalidate) {
// Simply use a drop down in all cases
UISelectOne input = FacesComponentUtility.createComponent(HtmlSelectOneMenu.class, null);
// Determine where to retrieve the values from
PropertyDynamicType propertyType = propertyDefinitionDynamic.getDynamicType();
DynamicPropertyRetriever retriever = DYNAMIC_PROPERTY_RETRIEVERS.get(propertyType);
if (retriever == null) {
throw new IllegalStateException("Attempt to render a dynamic property but no retrievers are " +
"configured for the type. Dynamic property type: " + propertyType + ", Definition: " +
propertyDefinitionDynamic);
}
// Retrieve the values and load them into UI options
List<DynamicConfigurationPropertyValue> values = retriever.loadValues(propertyDefinitionDynamic);
for (DynamicConfigurationPropertyValue option : values) {
UISelectItem selectItem = FacesComponentUtility.createComponent(UISelectItem.class, null);
selectItem.setItemLabel(option.getDisplay());
selectItem.setItemValue(option.getValue());
input.getChildren().add(selectItem);
}
boolean isUnset = isUnset(propertyDefinitionDynamic.isRequired(), property, isGroupConfig);
boolean isReadOnly = isReadOnly(propertyDefinitionDynamic.isReadOnly(), propertyDefinitionDynamic.isRequired(),
property, configReadOnly, configFullyEditable);
String propertyId = PropertyIdGeneratorUtility.getIdentifier(property, listIndex);
input.setId(propertyId);
// Revert to the previously selected value
input.setValueExpression("value", valueExpression);
FacesComponentUtility.setUnset(input, isUnset);
FacesComponentUtility.setReadonly(input, isReadOnly);
// If there is a PC-detected error associated with the property, associate it with the input.