marți, 27 octombrie 2015

[OmniFaces utilities (2.0)] Joins all elements of the an array to a single string, separated by the a separator


[OmniFaces utilities] The joinArray() function joins all elements of the given array to a single string, separated by the given separator.

Function:
Usages:

// example 1
<c:set var="alphabet" value="#{['A', 'B', 'C','D', 'E']}" />
#{of:joinArray(alphabet.toArray(),"+")}
Output:  A+B+C+D+E      

// example 2
public class MyBean {

 private String[] alphabetBean = {"a","b","c"};   

 public String[] getAlphabetBean() {
  return alphabetBean;
 }
}

Array to string: #{of:joinArray(myBean.alphabetBean,"+")}
Output:  a+b+c

// example 3
Array to string: #{of:joinArray(headerValues['Accept'],",")}
Output: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.

Niciun comentariu:

Trimiteți un comentariu