How to pass parameter to method using expression language (EL) in ADF?

Apparently there is not possible to pass parameter to java method using expression language. But it is possible to use Map as a return type for method. So - utilization of Map can benefit as a workaround for our needs.


Suppose in ADF faces page we need to print text with all line break symbols replaced with HTML <br> tags.

  • Create bean "utilsBean" with method "getBrFormattedString"

    public Map<String, String> getBrFormattedString() {
        return new HashMap<String, String>() {
            public String get(Object key) {
                String str = (String)key;
                str = str.replaceAll("(\\r|\\n|\\r\\n)+", "<br>");
                return str;


  • Create "af:outputFormatted" component

 <af:outputFormatted value="#{utilsBean.brFormattedString[requestScope.messageDetails]}"

As you can see, in this example Map is constructed dynamically and finally it acts as a regular method. We can put there any functionality we need. We could use any kind of object instead of String as well - Map<Object, Object>.

No comments:

Post a Comment