public Object getAsObject()

in myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/HtmlInputColorRenderer.java [124:162]


    public Object getAsObject(FacesContext context, UIComponent uiComponent, String value) throws ConverterException
    {

        if (value == null || value.toString().length() == 0)
        {
            return null;
        }
        else
        {
            HtmlInputColor component = (HtmlInputColor) uiComponent;
            String strValue = value.toString();

            if (SIMPLE_VALID_COLOR_PATTERN.matcher(strValue).matches())
            {
                return strValue;
            }
            else
            {
                String invalidColorMessage = component.getInvalidColorMessage();
                if (invalidColorMessage != null && invalidColorMessage.length() > 0)
                {
                    throw new ConverterException(new FacesMessage(FacesMessage.SEVERITY_ERROR, invalidColorMessage,
                            invalidColorMessage));
                }
                else
                {
                    // throw new ConverterException(_MessageUtils.getMessage(facesContext,
                    // facesContext.getViewRoot().getLocale(),
                    // FacesMessage.SEVERITY_ERROR, UIInput.REQUIRED_MESSAGE_ID,
                    // new Object[] { _MessageUtils.getLabel(facesContext,
                    // uiComponent) }));
                    // XXX: externalize and localize the message later!
                    throw new ConverterException(new FacesMessage("Provided value for component " + DebugUtils.getPathToComponent(uiComponent) + " is not a valid simple color: "
                            + value));
                }
            }
        }

    }