public FilterConstraint getFilterConstraint(Tree tree) { String filterMatchMode = tree.getFilterMatchMode(); FilterConstraint filterConstraint = Tree.FILTER_CONSTRAINTS.get(filterMatchMode); if (filterConstraint == null) { throw new FacesException("Illegal filter match mode:" + filterMatchMode); } return filterConstraint; } }
private String createPostParameters(FacesContext context, Object value) throws UnsupportedEncodingException { String privateKey = context.getApplication().evaluateExpressionGet(context, context.getExternalContext().getInitParameter(Captcha.PRIVATE_KEY), String.class); if (privateKey == null) { throw new FacesException("Cannot find private key for catpcha, use primefaces.PRIVATE_CAPTCHA_KEY context-param to define one"); } StringBuilder postParams = new StringBuilder(); postParams.append("secret=").append(URLEncoder.encode(privateKey, "UTF-8")); postParams.append("&response=").append(value == null ? "" : URLEncoder.encode((String) value, "UTF-8")); String params = postParams.toString(); postParams.setLength(0); return params; } }
Object value1 = sortBy.getValue(context.getELContext()); context.getExternalContext().getRequestMap().put(var, obj2); Object value2 = sortBy.getValue(context.getELContext()); result = (Integer) sortFunction.invoke(context.getELContext(), new Object[]{value1, value2}); throw new FacesException(e);
if (converter == null) { Class valueType = value.getClass(); converter = context.getApplication().createConverter(valueType); throw new FacesException("Value of " + component.getClientId(context) + " must be a List or an Array."); return (String) component.getAttributes().get("alt");
String submittedValue = context.getExternalContext().getRequestParameterMap().get(inputId); ValueExpression valueExpression = inputNumber.getValueExpression("value"); if (valueExpression != null) { Class<?> type = valueExpression.getType(context.getELContext()); if (type != null && type.isPrimitive() && !LangUtils.isValueBlank(inputNumber.getMinValue())) { throw new FacesException("Invalid number", ex);
public void invokeSetters(ELContext elContext, Object object) { for (Entry<Method, ValueExpression> entry : attributes.entrySet()) { try { entry.getKey().invoke(object, entry.getValue().getValue(elContext)); } catch (Exception e) { throw new FacesException(e); } } } }
public static final String getValue(FacesContext context, UICalendar calendar, Object value, String pattern) { //first ask the converter if (calendar.getConverter() != null) { return calendar.getConverter().getAsString(context, calendar, value); } else if (value instanceof String) { return (String) value; } //Use built-in converter else if (value instanceof Date) { SimpleDateFormat format = new SimpleDateFormat(pattern, calendar.calculateLocale(context)); format.setTimeZone(calculateTimeZone(calendar.getTimeZone())); return format.format((Date) value); } else { //Delegate to global defined converter (e.g. joda or java8) ValueExpression ve = calendar.getValueExpression("value"); if (ve != null) { Class type = ve.getType(context.getELContext()); if (type != null && type != Object.class && type != Date.class) { Converter converter = context.getApplication().createConverter(type); if (converter != null) { return converter.getAsString(context, calendar, value); } } } throw new FacesException("Value could be either String or java.util.Date"); } }
void decodeMultipleSelection(FacesContext context, DataTable table, String selection) { ValueExpression selectionByVE = table.getValueExpression(DataTable.PropertyKeys.selection.toString()); Class<?> clazz = selectionByVE == null ? null : selectionByVE.getType(context.getELContext()); boolean isArray = clazz == null ? false : clazz.isArray(); throw new FacesException("Multiple selection reference must be an Array or a List for datatable " + table.getClientId());
public FilterConstraint getFilterConstraint(UIColumn column) { String filterMatchMode = column.getFilterMatchMode(); FilterConstraint filterConstraint = TreeTable.FILTER_CONSTRAINTS.get(filterMatchMode); if (filterConstraint == null) { throw new FacesException("Illegal filter match mode:" + filterMatchMode); } return filterConstraint; } }
Object value1 = sortBy.getValue(context.getELContext()); context.getExternalContext().getRequestMap().put(var, ((TreeNode) obj2).getData()); Object value2 = sortBy.getValue(context.getELContext()); result = (Integer) sortFunction.invoke(context.getELContext(), new Object[]{value1, value2}); throw new FacesException(e);
public void invokeSetters(ELContext elContext, Object object) { for (Entry<Method, ValueExpression> entry : attributes.entrySet()) { try { entry.getKey().invoke(object, entry.getValue().getValue(elContext)); } catch (Exception e) { throw new FacesException(e); } } } }
Converter converter = context.getApplication().createConverter(value.getClass()); if (converter != null) { Object obj = converter.getAsObject(context, calendar, value.toString()); throw new FacesException("Value could be either String or java.util.Date");
public FilterConstraint getFilterConstraint(UIColumn column) { String filterMatchMode = column.getFilterMatchMode(); FilterConstraint filterConstraint = FILTER_CONSTRAINTS.get(filterMatchMode); if (filterConstraint == null) { throw new FacesException("Illegal filter match mode:" + filterMatchMode); } return filterConstraint; }
@Override public void processAction(ActionEvent event) { FacesContext context = FacesContext.getCurrentInstance(); ELContext elContext = context.getELContext(); String tables = (String) target.getValue(elContext); String exportAs = (String) type.getValue(elContext); String outputFileName = (String) fileName.getValue(elContext); if (repeat != null) { repeating = repeat.isLiteralText() ? Boolean.parseBoolean(repeat.getValue(context.getELContext()).toString()) : (Boolean) repeat.getValue(context.getELContext()); UIComponent component = (UIComponent) components.get(0); if (!(component instanceof DataTable)) { throw new FacesException("Unsupported datasource target:\"" + component.getClass().getName() + "\", exporter must target a PrimeFaces DataTable."); throw new FacesException(e);
@SuppressWarnings("unchecked") public static <T> T getValue(ValueExpression valueExpression, Class<T> expectedType) { try { return (T) valueExpression.getValue(getELContext()); } catch (ELException e) { throw new FacesException(e); } }
public static Resource newResource(ResourceInfo resourceInfo, FacesContext context) { Resource resource = context.getApplication().getResourceHandler().createResource(resourceInfo.getName(), resourceInfo.getLibrary()); if (resource == null) { throw new FacesException("Resource '" + resourceInfo.getName() + "' in library '" + resourceInfo.getLibrary() + "' not found!"); } return resource; }
public UITreeNode getUITreeNodeByType(String type) { UITreeNode node = getTreeNodes().get(type); if (node == null) { throw new javax.faces.FacesException("Unsupported tree node type:" + type); } else { return node; } }
@Override public void processAction(ActionEvent actionEvent) throws AbortProcessingException { FacesContext context = FacesContext.getCurrentInstance(); ELContext elContext = context.getELContext(); StreamedContent content = (StreamedContent) value.getValue(elContext); String contentDispositionValue = contentDisposition != null ? (String) contentDisposition.getValue(elContext) : "attachment"; String monitorKeyValue = monitorKey != null ? "_" + (String) monitorKey.getValue(elContext) : ""; throw new FacesException(e);
@Override public Object invoke(ELContext elContext, Object[] args) { Util.notNull("elContext", elContext); Object result = lookupExpression.getValue(elContext); if (result == null) { throw new FacesException("Unable to resolve composite component from using page using EL expression '" + lookupExpression.getExpressionString() + '\''); } if (!(result instanceof MethodExpression)) { throw new FacesException("Successfully resolved expression '" + lookupExpression.getExpressionString() + "', but the value is not a MethodExpression"); } return ((MethodExpression) result).invoke(elContext, args); }
protected void encodeCSS(FacesContext context, String library, String resource) throws IOException { ResponseWriter writer = context.getResponseWriter(); Resource cssResource = context.getApplication().getResourceHandler().createResource(resource, library); if (cssResource == null) { throw new FacesException("Error loading css, cannot find \"" + resource + "\" resource of \"" + library + "\" library"); } else { writer.startElement("link", null); writer.writeAttribute("type", "text/css", null); writer.writeAttribute("rel", "stylesheet", null); writer.writeAttribute("href", cssResource.getRequestPath(), null); writer.endElement("link"); } }