How to create a function or object property name in runtime via string concatenation?-Collection of common programming errors

I create portlets and there can be many instance of a portlet on a page, so that the functions and dom elements must be identified, AKA they must start with a particular namespace.

so that in some cases, I have to have my JS in a JSP page and cannot move it to a separate file, it is very inconvenient and hard to maintain.

a javascript in a JSP

var validator = new A.FormValidator({
        boundingBox: document.orderForm,

        validateOnBlur: true,
        validateOnInput: false,

        rules: {

            significanceLevel: {
                digits: true                
            },

            languageFrom: {
                required: true,
                notEqualTo: '#languageTo'
            },

            languageTo: {
                required: true,
                notEqualTo: '#languageFrom'
            }
}
......

From significanceLevel JSP generates _my_namespace_significanceLevel: . Even if I pass myNamespace (from a JS in JSP – namespaces resolved on serverside) into a constructor, I cannot create myNamespace + ‘methodName’ in runtime

Namespace is only known on serverSide. So that one JS always has to be in a JSP page so that is resolved and all other JS objects have it accessible via constructor parameter for instance.

this is one workaround, but it cannot be used in many cases :

window[instance._method] = function() {
    instance.fileAddError.apply(instance, arguments);
};

where the name of _method was concatenated from string literals