@Override public UIComponent resolveComponent(FacesContext context, UIComponent source, UIComponent last, String expression, int options) { throw new FacesException("jQuery selectors aka PFS are not supported on the server side... expression \"" + expression + "\" referenced from \"" + source.getClientId(context) + "\"."); }
private void validateIterationControlValues(int rowCount, int begin, int end) { if (rowCount == 0) { return; } // PENDING i18n if (begin > rowCount) { throw new FacesException("Iteration start index is greater than the number of available rows."); } if (begin > end) { throw new FacesException("Iteration start index is greater than the end index."); } if (end > rowCount) { throw new FacesException("Iteration end index is greater than the number of available rows."); } }
protected List resolveList(Object value) { if (value instanceof List) { return (List) value; } else if (value instanceof ListDataModel) { return (List) ((ListDataModel) value).getWrappedData(); } else { throw new FacesException("Data type should be java.util.List or javax.faces.model.ListDataModel instance to be sortable."); } } }
public static <T extends Renderer> T getUnwrappedRenderer(FacesContext context, String family, String rendererType, Class<T> rendererClass) { Renderer renderer = context.getRenderKit().getRenderer(family, rendererType); while (renderer instanceof FacesWrapper) { renderer = (Renderer) ((FacesWrapper) renderer).getWrapped(); } return (T) renderer; }
@Named @RequestScoped // Or @ViewScoped public class Bean { private Future<List<Entity>> asyncEntities; @EJB private EntityService entityService; @PostConstruct public void init() { asyncEntities = entityService.asyncList(); // ... (this code will immediately continue without waiting) } public List<Entity> getEntities() { try { return asyncEntities.get(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new FacesException(e); } catch (ExecutionException e) { throw new FacesException(e); } } }
@Override public UIComponent resolveComponent(FacesContext context, UIComponent source, UIComponent last, String expression, int options) { throw new FacesException("@row likely returns multiple components, therefore it's not supported in #resolveComponent... expression \"" + expression + "\" referenced from \"" + source.getClientId(context) + "\"."); }
public void postConstruct(Object obj) throws IllegalAccessException, InvocationTargetException { // WFLY-3387 MyFaces injects managed properties before calling this method try { injectionContainer.newInstance(obj); } catch (NamingException e) { throw new FacesException(e); } }
protected String extractId(String expression) { try { Matcher matcher = PATTERN.matcher(expression); if (matcher.matches()) { return matcher.group(1); } else { throw new FacesException("Expression does not match following pattern @id(id). Expression: \"" + expression + "\""); } } catch (Exception e) { throw new FacesException("Expression does not match following pattern @id(id). Expression: \"" + expression + "\"", e); } } }
private String decode(String encoded) { try { // GitHub #3916 escape + and % before decode encoded = encoded.replaceAll("%(?![0-9a-fA-F]{2})", "%25"); encoded = encoded.replaceAll("\\+", "%2B"); return URLDecoder.decode(encoded, "UTF-8"); } catch (UnsupportedEncodingException ex) { throw new FacesException(ex); } } }
protected UIData findDatasource(FacesContext context, Droppable droppable, String datasourceId) { UIComponent datasource = SearchExpressionFacade.resolveComponent(context, droppable, datasourceId); if (datasource == null) { throw new FacesException("Cannot find component \"" + datasourceId + "\" in view."); } else { return (UIData) datasource; } } }
public static byte[] toByteArray(InputStream stream) { try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); int nRead; byte[] data = new byte[16384]; while ((nRead = stream.read(data, 0, data.length)) != -1) { buffer.write(data, 0, nRead); } buffer.flush(); return buffer.toByteArray(); } catch (Exception e) { throw new FacesException("Could not read InputStream to byte[]", e); } }
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; } }
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; } }
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; }
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; } }
/** * Creates an RFC 6266 Content-Dispostion header following all UTF-8 conventions. * <p> * @param value e.g. "attachment" * @param filename the name of the file * @return a valid Content-Disposition header in UTF-8 format */ public static String createContentDisposition(String value, String filename) { try { return String.format("%s;filename=\"%2$s\"; filename*=UTF-8''%2$s", value, encodeURI(filename)); } catch (UnsupportedEncodingException e) { throw new FacesException(e); } }
@Override public V get(Object key) { if (!containsKey(key)) { throw new FacesException("Class " + clazz.getName() + " does not contain the enum " + key); } return super.get(key); } }
protected SelectItem[] getFilterOptions(UIColumn column) { Object options = column.getFilterOptions(); if (options instanceof SelectItem[]) { return (SelectItem[]) options; } else if (options instanceof Collection<?>) { return ((Collection<SelectItem>) column.getFilterOptions()).toArray(new SelectItem[]{}); } else { throw new FacesException("Filter options for column " + column.getClientId() + " should be a SelectItem array or collection"); } }
@Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { Captcha captcha = (Captcha) component; String publicKey = getPublicKey(context, captcha); if (publicKey == null) { throw new FacesException("Cannot find public key for catpcha, use primefaces.PUBLIC_CAPTCHA_KEY context-param to define one"); } encodeMarkup(context, captcha, publicKey); encodeScript(context, captcha, publicKey); }
public Object getRowKeyFromModel(Object object) { DataModel model = getDataModel(); if (!(model instanceof SelectableDataModel)) { throw new FacesException("DataModel must implement org.primefaces.model.SelectableDataModel when selection is enabled."); } return ((SelectableDataModel) getDataModel()).getRowKey(object); }