method invokeRichFacesJSAPIFunction in page fragments utils refactored in order to prevent ClassCastException