@JSFFaceletFunction(name="fn:indexOf") public static int indexOf(String name, String searchString) { if (name == null || searchString == null) { return -1; } return name.indexOf(searchString); }
@JSFFaceletFunction(name="fn:contains") public static boolean contains(String name, String searchString) { if (name == null || searchString == null) { return false; } return -1 != name.indexOf(searchString); }
@JSFFaceletFunction(name="fn:startsWith") public static boolean startsWith(String value, String p) { if (value == null || p == null) { return false; } return value.startsWith(p); }
@JSFFaceletFunction(name="fn:endsWith") public static boolean endsWith(String name, String searchString) { if (name == null || searchString == null) { return false; } return name.endsWith(searchString); }
@JSFFaceletFunction(name="fn:toUpperCase") public static String toUpperCase(String v) { if (v == null) { return ""; } if (v.length() == 0) { return ""; } return v.toUpperCase(); }
@JSFFaceletFunction(name="fn:trim") public static String trim(String v) { if (v == null) { return ""; } if (v.length() == 0) { return ""; } return v.trim(); }
@JSFFaceletFunction(name="fn:toLowerCase") public static String toLowerCase(String v) { if (v == null) { return ""; } if (v.length() == 0) { return ""; } return v.toLowerCase(); }
@JSFFaceletFunction(name="fn:containsIgnoreCase") public static boolean containsIgnoreCase(String name, String searchString) { if (name == null || searchString == null) { return false; } return -1 != name.toUpperCase().indexOf(searchString.toUpperCase()); }
@JSFFaceletFunction(name="fn:substringBefore") public static String substringBefore(String v, String s) { if (v == null) { return ""; } if (v.length() == 0) { return ""; } int i = v.indexOf(s); if (i > 0) { return v.substring(0, i); } return ""; }
@JSFFaceletFunction(name="fn:substringAfter") public static String substringAfter(String v, String p) { if (v == null) { return ""; } if (v.length() == 0) { return ""; } int i = v.indexOf(p); if (i >= 0) { return v.substring(i + p.length()); } return ""; }
@JSFFaceletFunction(name="fn:replace") public static String replace(String value, String a, String b) { if (value == null) { return ""; } if (value.length() == 0) { return ""; } if (a == null) { return value; } if (a.length() == 0) { return value; } if (b == null) { b = ""; } return value.replaceAll(a, b); }
/** * Return a UIComponent instance based on the passed findComponent * expression. The viewRoot instance is used as component reference * * @param expr * @return */ @JSFFaceletFunction(name="mc:findComponent") public static UIComponent findComponent(String expr) { return FacesContext.getCurrentInstance(). getViewRoot().findComponent(expr); }
@JSFFaceletFunction(name="fn:join") public static String join(String[] a, String delim) { if (a == null || delim == null) { return ""; } if (a.length == 0) { return ""; } StringBuilder sb = new StringBuilder(a.length * (a[0].length() + delim.length())); for (int i = 0; i < a.length; i++) { sb.append(a[i]); if (i < (a.length - 1)) { sb.append(delim); } } return sb.toString(); }
@JSFFaceletFunction(name="fn:length") public static int length(Object obj) { if (obj == null) { return 0; } if (obj instanceof Collection) { return ((Collection<?>) obj).size(); } if (obj.getClass().isArray()) { return Array.getLength(obj); } if (obj instanceof String) { return ((String) obj).length(); } if (obj instanceof Map) { return ((Map<?, ?>) obj).size(); } throw new IllegalArgumentException("Object type not supported: " + obj.getClass().getName()); }
/** * Invoke findComponent() taking as reference the passed component * and as param the expression defined. * * @param c * @param expr * @return */ @JSFFaceletFunction(name="mc:findComponentFrom") public static UIComponent findComponentFrom(UIComponent c, String expr) { if (c != null) { return c.findComponent(expr); } return null; } }
@JSFFaceletFunction(name="fn:substring") public static String substring(String v, int s, int e) { if (v == null) { return ""; } if (v.length() == 0) { return ""; } if (s >= v.length()) { return ""; } if (s < 0) { s = 0; } if (e >= v.length()) { e = v.length(); } if (e < s) { return ""; } return v.substring(s, e); }
/** * Return the client id of the component returned by the findComponent * expression. * * @param expr * @return */ @JSFFaceletFunction(name="mc:outputClientId") public static String outputClientId(String expr) { FacesContext ctx = FacesContext.getCurrentInstance(); return ctx.getViewRoot().findComponent(expr).getClientId(ctx); }
@JSFFaceletFunction(name="fn:split") public static String[] split(String value, String d)
@JSFFaceletFunction(name="fn:escapeXml") public static String escapeXml(String value)