Concatenate strings in JSF/JSP EL and Javascript [duplicate]

Assuming you are using Facelets, here's a relatively good solution:

  • create functions.taglib.xml in your WEB-INF
  • add a context param indicating the location:

    <context-param>
        <param-name>facelets.LIBRARIES</param-name>
        <param-value>
            /WEB-INF/functions.taglib.xml
        </param-value>
    </context-param>
    
  • In the xml put the following:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE facelet-taglib PUBLIC
      "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
      "https://facelets.dev.java.net/source/browse/*checkout*/facelets/src/etc/facelet-taglib_1_0.dtd">
    <facelet-taglib xmlns="http://java.sun.com/JSF/Facelet">
        <namespace>http://yournamespace.com/fnc</namespace>
        <function>
            <function-name>concat</function-name>
            <function-class>com.yourpackage.utils.Functions</function-class>
            <function-signature>
                java.lang.String concat(java.lang.String, java.lang.String)
            </function-signature>
        </function>
    </facelet-taglib>
    
  • in the page use the following:

    xmlns:fnc="http://yournamespace.com/fnc"
    ....
    oncomplete="#{rich:component(fnc:concat(prefix, '_examinationPanel'))}.show();"
    
  • finally, in the Function class define the simple method:

    public static String concat(String string1, String string2) {
       return string1.concat(string2);
    }
    

a simpler solution is to manage the String in the EL like an Object and use the method concat from the class String, something like this:

#{rich:component('constantString'.concat(variable))}.show();