private static boolean isInvalidRequiredProperty(boolean isRequired, PropertySimple propertySimple) { boolean isInvalidRequiredProperty = false; if (isRequired) { String errorMessage = propertySimple.getErrorMessage(); if ((null == propertySimple.getStringValue()) || "".equals(propertySimple.getStringValue()) || ((null != errorMessage) && (!"".equals(errorMessage.trim())))) { // Required properties with no value, or an invalid value (assumed if we see an error message) should // never be set to read-only, otherwise the user will have no way to give the property a value and // thereby get things to a valid state. isInvalidRequiredProperty = true; } } return isInvalidRequiredProperty; } }
private static void addPluginContainerDetectedErrorMessage(UIInput input, PropertySimple propertySimple) { String errorMsg = (propertySimple != null) ? propertySimple.getErrorMessage() : null; if ((errorMsg != null) && !errorMsg.equals("")) { FacesContext facesContext = FacesContextUtility.getFacesContext(); FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, errorMsg, null); // NOTE: It's vital to pass the client id, *not* the component id, to addMessage(). facesContext.addMessage(input.getClientId(facesContext), facesMsg); } }
private boolean isInvalidRequiredProperty(PropertyDefinition propertyDefinition) { boolean isInvalidRequiredProperty = false; if ((propertyDefinition instanceof PropertyDefinitionSimple) && propertyDefinition.isRequired()) { PropertySimple propertySimple = this.propertyMap.getSimple(propertyDefinition.getName()); String errorMessage = propertySimple.getErrorMessage(); if ((null == propertySimple.getStringValue()) || "".equals(propertySimple.getStringValue()) || ((null != errorMessage) && (!"".equals(errorMessage.trim())))) { // Required properties with no value, or an invalid value (assumed if we see an error message) should never // be set to read-only, otherwise the user will have no way to give the property a value and thereby // get things to a valid state. isInvalidRequiredProperty = true; } } return isInvalidRequiredProperty; }