Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* The MIT License
*
* Copyright (c) 2009-2023 PrimeTek Informatics
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.primefaces.component.colorpicker;
import java.io.IOException;
import java.util.Map;
import java.util.regex.Pattern;
import javax.faces.component.UIComponent;
import javax.faces.component.UINamingContainer;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.convert.Converter;
import org.primefaces.renderkit.InputRenderer;
import org.primefaces.util.*;
public class ColorPickerRenderer extends InputRenderer {
private static final Pattern COLOR_PATTERN = Pattern.compile(
"^#(?:[\\da-f]{3}){1,2}$|^#(?:[\\da-f]{4}){1,2}$|(rgb|hsl)a?\\((\\s*-?\\d+%?\\s*,){2}(\\s*-?\\d+%?\\s*)\\)"
+ "|(rgb|hsl)a?\\((\\s*-?\\d+%?\\s*,){3}\\s*(0|(0?\\.\\d+)|1)\\)", Pattern.CASE_INSENSITIVE);
@Override
public void decode(FacesContext context, UIComponent component) {
ColorPicker colorPicker = (ColorPicker) component;
if (!shouldDecode(colorPicker)) {
return;
}
Map params = context.getExternalContext().getRequestParameterMap();
String paramName = colorPicker.getClientId(context);
boolean inline = !"popup".equalsIgnoreCase(colorPicker.getMode());
if (inline) {
paramName = paramName + "_color";
if (!params.containsKey(paramName)) {
paramName = "clr-color-value";
}
}
if (params.containsKey(paramName)) {
String submittedValue = params.get(paramName);
if (!COLOR_PATTERN.matcher(submittedValue).matches()) {
submittedValue = Constants.EMPTY_STRING;
}
colorPicker.setSubmittedValue(submittedValue);
}
decodeBehaviors(context, component);
}
@Override
public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
ColorPicker colorPicker = (ColorPicker) component;
Converter