PrimeFaces Mobile 请求 undefined/undefined.css 和 undefined/undefined.js,导致 JSF1064 警告和 404 错误

PrimeFaces Mobile requests undefined/undefined.css and undefined/undefined.js, causing JSF1064 warning and 404 error

当我将 <p:selectBooleanButton> 添加到我的 PrimeFaces Mobile 页面时,我在服务器日志中收到以下警告

WARNING: JSF1064: Unable to find or serve resource, undefined/undefined.css, from library, primefaces.
Jan 11, 2015 3:00:36 PM com.sun.faces.application.resource.ResourceHandlerImpl logMissingResource

浏览器控制台出现以下错误:

404 (Not Found) http://localhost:8080/ewpmob/javax.faces.resource/undefined/undefined.js.xhtml?ln=primefaces&v=5.1.7

这是怎么造成的,我该如何解决?

这是 PrimeFaces 移动版中的错误。这是在以下相关答案中发现并充实的:Why is my p:progressBar not displayed, only the number?

解决方法是,在头部结尾或主体开头执行此脚本,内联或通过自定义脚本文件:

var originalPrimeFacesCw = PrimeFaces.cw;
PrimeFaces.cw = function(name, id, options, resource) {
    resource = resource || name.toLowerCase();
    originalPrimeFacesCw.apply(this, [name, id, options, resource]);
};