package com.nesterovskyBros; import java.util.AbstractList; import java.util.Collections; import java.util.List; import javax.el.ValueExpression; import javax.faces.context.FacesContext; /** * JSF functions used in the application. */ public class Functions { /** * Resolves resource url. * * @param path resource path, possibly relative. * @return resolved path. */ public static String url(String path) throws Exception { FacesContext facesContext = FacesContext.getCurrentInstance(); return facesContext.getApplication().getViewHandler(). getResourceURL(facesContext, path); } /** * A factory of {@link ScopeComponent} instances. */ public static class ScopeProvider { /** * Gets an instance of {@link ScopeComponent}. * @return an instance of {@link ScopeComponent}. */ public ScopeComponent getValue() { if (value == null) { value = new ScopeComponent(); } return value; } /** * Sets a value of {@link ScopeComponent}. * @param value a value of {@link ScopeComponent}. */ public void setValue(ScopeComponent value) { this.value = value; } /** * A scope component. */ private ScopeComponent value; } /** *
Creates a scope component.
*{@link ScopeComponent} introduces itself into the databinding scope * using value of id attribute as name, allowing to acquire its clientId.
** <f:subview id="name" binding="#{ex:scope()}"> * ... * #{name.childId}:item * <f:subview> *
*The other feature is uniqueId attribute, which is used to output * something only once. uniqueId is used as a discriminator. *
* <f:subview uniqueId="my-script-id" binding="ex:scope()"> * <script ... * <f:subview> *
* @return an instance of {@link ScopeComponent}. */ public static Object scope() throws Exception { return new ScopeProvider(); } /** * Returns a list of integers with values from 0 and up to size not including. * @param size a size of list. * @return a list of integers. */ public static List