简体   繁体   English

当javax.faces.PROJECT_STAGE为Production时,未定义mojarra

[英]mojarra is not defined when javax.faces.PROJECT_STAGE is Production

Today I got the exception "mojarra is not defined". 今天,我得到了一个例外:“未定义mojarra”。

I stumbled in the following questions: This , this and this . 我偶然发现了以下问题: 这个这个这个

Neither of those solver my issue. 这些问题都不是我的问题。

After some debugging I fixed the issue by changing javax.faces.PROJECT_STAGE param in web.xml from: 经过一些调试后,我通过从以下位置更改web.xml中的javax.faces.PROJECT_STAGE参数来解决此问题:

<param-value>Production</param-value>

to: 至:

<param-value>Development</param-value>

It fixed the issue, but what should I do when putting my project in production? 它解决了该问题,但是将项目投入生产时应该怎么做? Should I leave the param on development? 我应该把发展的主题留给别人吗?

My component calls mojarra.ab(this,event,'valueChange',0,'menu-form:pagina-select') in development mode the jsf.js is mojarra, but when in production mode it seems to be a minified version of my faces, small extract of the beginning of the jsf.js in production mode: if(!window.myfaces){var myfaces=new function(){};window.myfaces=myfaces;}, even though my component still call mojarra.ab(...). 我的组件在开发模式下调用mojarra.ab(this,event,'valueChange',0,'menu-form:pagina-select')jsf.js是mojarra,但在生产模式下,它似乎是mojarra的缩小版本我的脸,是生产模式下jsf.js开头的小部分摘录:即使我的组件仍然调用mojarra,if(!window.myfaces){var myfaces = new function(){}; window.myfaces = myfaces;} .ab(...)。 I'll double check my server configuration 我将仔细检查服务器配置

You've apparently experimented with both Mojarra and MyFaces and the MyFaces version of jsf.js is hanging in an agressive cache somewhere in the network pipeline. 您显然已经对Mojarra和MyFaces进行了试验,并且jsf.js的MyFaces版本挂在网络管道中某处的jsf.js性缓存中。 Clear at least the browser's and, if any, also the proxy's cache. 至少清除浏览器的缓存,如果有的话,还要清除代理的缓存。

That it works in development stage is because the URL of the jsf.js contains an additional query string unique to Mojarra (it would return a non-minified version to ease debugging). 它在开发阶段起作用的原因是jsf.js的URL包含一个Mojarra唯一的附加查询字符串(它将返回非最小版本以简化调试)。

i ran into same trouble these days and i figured out, that it was caused by my extendend omnifaces resourcehandler. 这些天我遇到了同样的麻烦,我发现这是由我的扩展无所不在的资源处理程序引起的。

public class VersionableResourceHandler extends DefaultResourceHandler {
  //...
  @Override
  public Resource decorateResource(Resource resource) {
    if (resource == null) {
        return resource;
    }
    return new RemappedResource(resource, resource.getRequestPath() + "?v=1_2_1");
  }
}

with

<param-value>Development</param-value>

the generated output with my appended version-string will be: 带有我附加的版本字符串的生成的输出将是:

 <script type="text/javascript" src="/javax.faces.resource/jsf.js?ln=javax.faces&amp;stage=Development%3Fv=1_2_1"/>

with

<param-value>Production</param-value>

generated output looks like: 生成的输出如下所示:

<script type="text/javascript" src="/javax.faces.resource/jsf.js?ln=javax.faces%3Fv=1_2_1"/>

which is invalid because of the second "?", so "?v=1_2_1" had to be replaced by "&v=1_2_1". 由于第二个“?”而无效,因此必须将“?v = 1_2_1”替换为“&v = 1_2_1”。

I had exactly the same issue, it was a conflict between JSF and PrimeFace. 我有完全相同的问题,这是JSF和PrimeFace之间的冲突。 (If you are using primeface) (如果您使用的是primeface)

I previously use <h:commandLink actionListener="#controller.upadte"> and the solution is to use <p:commandLink actionListener="#controller.upadte"> 我以前使用<h:commandLink actionListener="#controller.upadte"> ,解决方案是使用<p:commandLink actionListener="#controller.upadte">

I hope this solution works for you. 希望此解决方案对您有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM