+ input.getClientId(context) + "\" because the ValueExpression of the \"value\" attribute" + " isn't resolvable completely (e.g. a sub-expression returns null)";
@Override public void transformInput(FacesContext context, PrimeApplicationContext applicationContext, UIInput input) throws IOException { EditableValueHolder editableValueHolder = (EditableValueHolder) input; if (editableValueHolder.isRequired() && isMaxlenghtSet(input)) { return; } try { Set<ConstraintDescriptor<?>> constraints = BeanValidationMetadataExtractor.extractDefaultConstraintDescriptors( context, applicationContext, input.getValueExpression("value")); if (constraints != null && !constraints.isEmpty()) { for (ConstraintDescriptor<?> constraintDescriptor : constraints) { applyConstraint(constraintDescriptor, input, editableValueHolder); } } } catch (PropertyNotFoundException e) { String message = "Skip transform metadata for component \"" + input.getClientId(context) + "\" because" + " the ValueExpression of the \"value\" attribute" + " isn't resolvable completely (e.g. a sub-expression returns null)"; LOGGER.log(Level.FINE, message); } }
public String getClientId(FacesContext context) { return super.getClientId(context); }
public Object getValue(FacesContext facesContext) throws EvaluationException, PropertyNotFoundException { //PartialSubmit dictates that we obey "required" only for //the single component causing the PartialSubmit. Components //used in an iterative fashion have different client IDs for //the same UIComponent instance. if (clientId.equals(input.getClientId(facesContext))) { return wrapped.getValue(facesContext); } return Boolean.FALSE; }
private static String getHtmlDomReference(UIInput input, UIForm form, char quoteChar) { FacesContext facesContext = FacesContext.getCurrentInstance(); String inputHtmlDomReference = "document." + form.getClientId(facesContext) + "[" + quoteChar + input.getClientId(facesContext) + quoteChar + "]"; return inputHtmlDomReference; }
public String getOwnClientId(FacesContext context) { AssertionUtil.assertNotNull("context", context); return super.getClientId(context); }
@Override public String getClientId(FacesContext facesContext) { return getWrapped().getClientId(facesContext); }
@Override public String getClientId(FacesContext facesContext) { return getWrapped().getClientId(facesContext); }
public static boolean isError(final UIInput uiInput) { final FacesContext facesContext = FacesContext.getCurrentInstance(); return !uiInput.isValid() || facesContext.getMessages(uiInput.getClientId(facesContext)).hasNext(); }
@Override public void decode(final FacesContext facesContext, final UIComponent component) { final UIInput input = (UIInput) component; if (ComponentUtils.isOutputOnly(input)) { return; } final String newValue = facesContext.getExternalContext() .getRequestParameterMap().get(input.getClientId(facesContext)); if (LOG.isDebugEnabled()) { LOG.debug("new value = '" + newValue + "'"); } input.setSubmittedValue("true".equals(newValue) ? "true" : "false"); RenderUtils.decodeClientBehaviors(facesContext, input); }
public boolean guestbookResponseValidator( UIInput toValidate, String value) { if (value != null && value.length() > 255) { (toValidate).setValid(false); FacesContext.getCurrentInstance().addMessage((toValidate).getClientId(), new FacesMessage( FacesMessage.SEVERITY_ERROR, BundleUtil.getStringFromBundle("dataset.guestbookResponse.guestbook.responseTooLong"), null)); return false; } return true; }
private static void invalidateInputsByPropertyPathAndShowMessages(FacesContext context, UIForm form, Object bean, Map<String, String> violations) { for (Entry<String, String> violation : violations.entrySet()) { forEachInputWithMatchingBase(context, form, bean, violation.getKey(), input -> { context.validationFailed(); input.setValid(false); String clientId = input.getClientId(context); addError(clientId, violation.getValue(), getLabel(input)); }); } }
private static void invalidateInputsByPropertyPathAndShowMessages(FacesContext context, UIForm form, Object bean, Map<String, String> violations) { for (Entry<String, String> violation : violations.entrySet()) { forEachInputWithMatchingBase(context, form, bean, violation.getKey(), input -> { context.validationFailed(); input.setValid(false); String clientId = input.getClientId(context); addError(clientId, violation.getValue(), getLabel(input)); }); } }
public boolean validateSelectedDataverse() { if (selectedDestinationDataverse == null) { FacesContext.getCurrentInstance().addMessage(getSelectedDataverseMenu().getClientId(), new FacesMessage(FacesMessage.SEVERITY_ERROR, "", BundleUtil.getStringFromBundle("harvestclients.newClientDialog.dataverse.required"))); return false; } return true; }
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); } }
@Override public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException { UIInput taglineInput = (UIInput) component.getAttributes().get("taglineInput"); UIInput linkUrlInput = (UIInput) component.getAttributes().get("linkUrlInput"); String taglineStr = (String) taglineInput.getSubmittedValue(); String urlStr = (String) linkUrlInput.getSubmittedValue(); FacesMessage msg = null; if (taglineStr.isEmpty() && !urlStr.isEmpty()) { msg = new FacesMessage(BundleUtil.getStringFromBundle("link.tagline.validate")); msg.setSeverity(FacesMessage.SEVERITY_ERROR); FacesContext.getCurrentInstance().addMessage(taglineInput.getClientId(), msg); } if (msg != null) { throw new ValidatorException(msg); } }
protected void handleValidationException(FacesContext context, ValidatorException e) { setValid(false); FacesMessage message = e.getFacesMessage(); if (message != null) { message.setSeverity(FacesMessage.SEVERITY_ERROR); context.addMessage(getClientId(context), message); } } }
protected void handleConverterException(FacesContext context, ConverterException e) { setValid(false); FacesMessage facesMessage = e.getFacesMessage(); if (facesMessage != null) { context.addMessage(getClientId(context), facesMessage); } else { Object[] args = new Object[] { UIComponentUtil.getLabel(this) }; FacesMessageUtil.addErrorComponentMessage(context, this, CONVERSION_MESSAGE_ID, args); } }
private static void prevalidatePropertyValue(UIInput propertyValueInput, PropertySimple propertySimple, PropertySimpleValueValidator validator) { FacesContext facesContext = FacesContextUtility.getFacesContext(); try { String value = (propertySimple != null) ? propertySimple.getStringValue() : null; validator.validate(facesContext, propertyValueInput, value); } catch (ValidatorException e) { // NOTE: It's vital to pass the client id, *not* the component id, to addMessage(). facesContext.addMessage(propertyValueInput.getClientId(facesContext), e.getFacesMessage()); } }
public void validateSetQuery() { int datasetsFound = 0; try { datasetsFound = oaiSetService.validateDefinitionQuery(getNewSetQuery()); } catch (OaiSetException ose) { FacesContext.getCurrentInstance().addMessage(getNewSetQueryInputField().getClientId(), new FacesMessage(FacesMessage.SEVERITY_ERROR, "", BundleUtil.getStringFromBundle("harvest.search.failed")+ose.getMessage())); setSetQueryValidated(false); return; } setSetQueryValidated(true); setSetQueryResult(datasetsFound); }