private static boolean isOptional(PropertyDefinitionSimple propertyDefinitionSimple) { return propertyDefinitionSimple == null || !propertyDefinitionSimple.isRequired(); }
/** * Simple map property parsing. * * @param property raw map property * @param propertyDefinition property definition * @return parsed map, can be empty if no members were set. */ protected Map<String, Object> prepareSimplePropertyMap(PropertyMap property, PropertyDefinitionMap propertyDefinition) { Map<String, PropertyDefinition> memberDefinitions = propertyDefinition.getMap(); Map<String, Object> results = new HashMap<String, Object>(); for (String name : memberDefinitions.keySet()) { PropertyDefinition memberDefinition = memberDefinitions.get(name); if (memberDefinition.isReadOnly()) continue; if (memberDefinition instanceof PropertyDefinitionSimple) { PropertyDefinitionSimple pds = (PropertyDefinitionSimple) memberDefinition; PropertySimple ps = (PropertySimple) property.get(name); if ((ps == null || ps.getStringValue() == null) && !pds.isRequired()) continue; if (ps != null) results.put(name, ps.getStringValue()); } else { log.error(" *** not yet supported *** : " + memberDefinition.getName()); } } return results; }
if (!propDef.isRequired() && property.getStringValue()==null) { return; if (propDef.isRequired() && property.getStringValue()==null) { messages.add(prefix + "required but was 'null'"); return;
public void validate(FacesContext facesContext, UIComponent component, Object value) throws ValidatorException { String stringValue = (String) value; String refresh = FacesContextUtility.getOptionalRequestParameter("refresh"); if (refresh != null && refresh.equals(ConfigRenderer.PROPERTY_SET_COMPONENT_ID)) return; // An optional property with a null value is always valid. if (!this.propertyDefinition.isRequired() && value == null) return; // Don't validate if it's not being updated. if (!FacesComponentUtility.isOverride(component)) return; List<Validator> subValidators = createSubValidators(); for (Validator subValidator : subValidators) { try { subValidator.validate(facesContext, component, stringValue); } catch (ValidatorException e) { component.getAttributes().put("styleClass", INPUT_ERROR_STYLE_CLASS); if (" ".equals(stringValue)) { ((UIInput)component).setSubmittedValue(""); } throw e; } } }
private static void addValidatorsAndConverter(UIInput input, PropertyDefinitionSimple propertyDefinitionSimple, boolean readOnly,TemplateEngine templateEngine ) { if (!readOnly) { input.setRequired(propertyDefinitionSimple.isRequired()); input.addValidator(new PropertySimpleValueValidator(propertyDefinitionSimple)); input.setConverter(new PropertySimpleValueConverter(templateEngine)); } }
if (isOptional(propertyDefinitionSimple)) { FacesComponentUtility.addOutputText(panelGrid, null, "Unset All: ", null); unsetCheckbox = PropertyRenderingUtility.addUnsetControl(panelGrid, propertyDefinitionSimple.isRequired(), propertyDefinitionSimple.isReadOnly(), null, propertySetComponent.getListIndex(), input, false, propertySetComponent.getReadOnly(), false);
private void createWriteAttributePropertySimple(CompositeOperation cop, PropertySimple property, PropertyDefinitionSimple propertyDefinition, Address address) { if (property.getName().endsWith(":ignore")) // Caller takes care return; if (propertyDefinition.isReadOnly() && !createChildRequested) return; //If the property value is null and the property is optional, //then send default value or null to the server if (property.getStringValue() == null && !propertyDefinition.isRequired()) { String name = property.getName(); if (name.indexOf(':') != -1) { name = name.substring(0, name.indexOf(":")); } Operation writeAttribute = new WriteAttribute(address, name, null); cop.addStep(writeAttribute); return; } SimpleEntry<String, Object> entry = this.preparePropertySimple(property, propertyDefinition); Operation writeAttribute = new WriteAttribute(address, entry.getKey(), entry.getValue()); cop.addStep(writeAttribute); }
if (property.getStringValue() == null && propertyDefinition.isRequired()) { o = getObjectWithType(propertyDefinition, propertyDefinition.getDefaultValue()); } else {
PropertySimple loadHandlePropertySimple(PropertyDefinitionSimple propDef, Object valueObject) { PropertySimple propertySimple; String name = propDef.getName(); if (valueObject != null) { // Property is non-null -> return it. if (valueObject instanceof Map) { // If this is a map and no single type, get the EXPRESSION_VALUE Object o = ((Map) valueObject).get("EXPRESSION_VALUE"); propertySimple = new PropertySimple(name, o); } else { propertySimple = new PropertySimple(name, valueObject); } } else { // property is null? Check if it is required if (propDef.isRequired()) { String defaultValue = ((PropertyDefinitionSimple) propDef).getDefaultValue(); propertySimple = new PropertySimple(name, defaultValue); } else { // Not required and null -> return null propertySimple = new PropertySimple(name, null); } } return propertySimple; }
@NotNull public static UIInput createInputForSimpleProperty(PropertyDefinitionSimple propertyDefinitionSimple, PropertySimple propertySimple, ValueExpression propertyValueExpression, Integer listIndex, boolean isGroupConfig, boolean configReadOnly, boolean configFullyEditable, boolean prevalidate, TemplateEngine templateEngine) { UIInput input = createInput(propertyDefinitionSimple); if (propertySimple != null) addTitleAttribute(input, propertySimple.getStringValue()); boolean isUnset = isUnset(propertyDefinitionSimple.isRequired(), propertySimple, isGroupConfig); boolean isReadOnly = isReadOnly(propertyDefinitionSimple.isReadOnly(), propertyDefinitionSimple.isRequired(), propertySimple, configReadOnly, configFullyEditable); String propertyId = PropertyIdGeneratorUtility.getIdentifier(propertySimple, listIndex); input.setId(propertyId); input.setValueExpression("value", propertyValueExpression); FacesComponentUtility.setUnset(input, isUnset); FacesComponentUtility.setReadonly(input, isReadOnly); addValidatorsAndConverter(input, propertyDefinitionSimple, configReadOnly, templateEngine); addErrorMessages(input, propertyDefinitionSimple, propertySimple, prevalidate); return input; }
/** * Copies the parameters of an OperationDefinition into to an object that can be * returned to a REST-client, so that this knows which fields are to be filled in, * of which type they are and which ones are required * @param def OperationsDefinition to "copy" * @param definitionRest The definition to fill in */ private void copyParamsForDefinition(OperationDefinition def, OperationDefinitionRest definitionRest) { ConfigurationDefinition cd = def.getParametersConfigurationDefinition(); if (cd==null) { return; } for (Map.Entry<String,PropertyDefinition> entry : cd.getPropertyDefinitions().entrySet()) { PropertyDefinition pd = entry.getValue(); if (pd instanceof PropertyDefinitionSimple) { PropertyDefinitionSimple pds = (PropertyDefinitionSimple) pd; SimplePropDef prop = new SimplePropDef(); prop.setName(pds.getName()); prop.setRequired(pds.isRequired()); prop.setType(pds.getType()); prop.setDefaultValue(pds.getDefaultValue()); definitionRest.addParam(prop); } log.debug("copyParams: " + pd.getName() + " not yet supported"); } }
private int addNewMap(AbstractConfigurationComponent config) { String listName = config.getListName(); PropertyDefinitionMap mapDefinition = (PropertyDefinitionMap) config.getConfigurationDefinition() .getPropertyDefinitionList(listName).getMemberDefinition(); String mapName = mapDefinition.getName(); PropertyMap newMap = new PropertyMap(mapName); for (PropertyDefinition mapMemberDefinition : mapDefinition.getOrderedPropertyDefinitions()) { PropertyDefinitionSimple simpleDefinition = (PropertyDefinitionSimple) mapMemberDefinition; newMap.put(new PropertySimple(simpleDefinition.getName(), (simpleDefinition.isRequired()) ? "" : null)); } PropertyList list = config.getConfiguration().getList(listName); list.add(newMap); return list.getList().size() - 1; }
if (defaultValue != null || listMemberDefinitionSimple.isRequired()) { PropertySimple listSimple = new PropertySimple(listMemberDefinitionSimple.getName(), defaultValue);
propertyDefinitionSimple.isRequired(), null, configReadOnly,false); HtmlPanelGroup setAllToSameValueControlPanel = null; if (!propIsReadOnly) {
|| (!propertyDefinition.isRequired() && propertySimple.getStringValue() == null)) { isEntryEligible = false; } else {
if (!def.isRequired()) { PropertySimple prop = report.getConfiguration().getSimple(key); if (prop instanceof PropertySimple) {
if (!propertyDefinitionSimple.isRequired()) PropertyRenderingUtility.addUnsetControl(parent, propertyDefinitionSimple.isRequired(), propertyDefinitionSimple.isReadOnly(), propertySimple, this.config.getListIndex(), input, this.isGroup, this.config.isReadOnly(), this.config.isFullyEditable());
+ CssStyleClasses.MEMBER_PROPERTY_UNSET_CELL + "'>"); HtmlSelectBooleanCheckbox unsetCheckbox = PropertyRenderingUtility.addUnsetControl(propertySetComponent, propertyDefinitionSimple.isRequired(), propertyDefinitionSimple.isReadOnly(), propertyInfo.getProperty(), propertySetComponent.getListIndex(), input, false, propertySetComponent.getReadOnly(), false); propertyInfo.setUnsetCheckbox(unsetCheckbox);