【问题标题】:Menu weird rendering behaviour菜单奇怪的渲染行为
【发布时间】:2012-02-14 01:07:58
【问题描述】:

抱歉这篇文章的长度,但目前我们一无所知,所以我希望发布尽可能多的细节。
我们在 Internet Explorer 9 上遇到 primefaces 2.2 菜单问题。 我们使用eclipse开发web应用,服务器是tomcat,版本6.0.18,因客户要求无法升级。我们在战争中包含了所有必需的库,这也是客户的要求。下面是我们在应用程序 web-inf/lib 文件夹中包含的(详尽的)库列表:

  • Primefaces 2.2.1
  • antlr 2.7.6
  • commons-collections 3.1
  • commons-fileupload 1.2.1
  • commons-io 1.4
  • dom4j 1.6.1
  • 休眠 jpa 2.0 api 1.0.0 最终版
  • 休眠 3
  • itext-xtra 5.1.3
  • itextpdf 5.1.3
  • javassist 3.12.0 ga
  • jsf-api Mojarra JSF API 实现 2.1.1 (20110408-​​FCS)
  • jsf-impl(如上,已验证阅读清单)
  • jstl 1.2
  • jta 1.1
  • log4j 1.2.15
  • 雷德蒙德 1.0.1
  • slf4j-api 1.6.1
  • slf4j-log4j12-1.6.4
  • xmlworker - 1.1.1
  • commons-email 1.2

到目前为止,我们已经在三种不同的情况下测试了该应用程序:

  1. 开发环境:localhost tomcat 6.0.18,eclipse,ie9,http
  2. 部署的应用程序:tomcat 6.0.18、https - TAM(一个 ibm tivoli sso 系统)、ie9
  3. 部署的应用程序:tomcat 6.0.18、https - TAM(ibm tivoli sso 系统)、firefox 9

该菜单包含三个根菜单“新请求”、“正在进行的工作”和“管理”。
对于这两种情况 1. 和 2.(涉及 ie9),第二个菜单“正在进行中”在导航期间消失并重新出现(单击其他菜单,单击重定向按钮,...),其他两个仍然可见。我们无法找到规则,也无法系统地复制这种行为。 正如您从下面的代码中看到的那样,我们已经对子菜单设置器进行了注释,以检查是否存在将其设置为不同内容的编程错误。
使用 Firefox,它永远不会发生,它工作正常。 最后,仅在情况 2(ie9 + https over tam)中,我们有时会遇到 servlet 渲染异常,直到现在我们得到以下情况:

  • javax.servlet.ServletException: javax.servlet.jsp.JspException: java.lang.IllegalStateException: Parent 不为 null,但此组件不相关
  • javax.servlet.ServletException:菜单栏必须在表单元素内
  • ArrayIndexOutOfBounds

行为怪异的primefaces菜单是由代码构建的,它的backing bean有一个会话范围,下面列出了相关代码。
那么这是图书馆的问题吗?浏览器问题?我们的应用程序的错误? 有人可以建议一些测试来缩小问题或获得一些提示的工具吗?
主容器页面是:

<h:body>
<h:form id="masterForm">
    <p:growl id="msg" life="10000" showDetail="true" sticky="false" />
</h:form>
<p:layout fullPage="true">
    <p:layoutUnit position="top" height="90" id="layUnitNorth"
        resizable="false" closable="false" collapsible="false"  
        scrollable="null" zindex="199">
        <ui:insert name="header">
            <div id="userInfoPanel">
                <ui:include src="userinfo.xhtml" />
            </div>              
            <ui:include src="menu.xhtml" /> 
        </ui:insert>
    </p:layoutUnit>

    <p:layoutUnit position="center" scrollable="true">
        <ui:insert name="content">
            <p:layoutUnit position="center">
            </p:layoutUnit>
        </ui:insert>
    </p:layoutUnit>
</p:layout>

菜单页面是:

<ui:composition>
<h:form id="menuForm">
    <p:menubar effect="slide" styleClass="menuCustom">
        <p:submenu label="New" >
            <p:menuitem value="new requests" onclick="navigateTo('Richieste/ListaRichieste.xhtml?canale=0');" />
            <p:menuitem value="channel 1" onclick="navigateTo('Richieste/ListaRichieste.xhtml?canale=1');" />
            <p:menuitem value="channel 2" onclick="navigateTo('Richieste/ListaRichieste.xhtml?canale=2');" />
            <p:menuitem value="channel 3" onclick="navigateTo('Richieste/ListaRichieste.xhtml?canale=3');" />
        </p:submenu>
        <p:submenu label="work in progress"
            binding="#{menuCtrl.boxSubMenu}">
        </p:submenu>
        <p:submenu label="administration" rendered="#{userInfo.admin}">
            <p:menuitem value="Customers" url="#" />
            <p:menuitem value="Templates" url="#" />
            <p:menuitem value="Digital signature" url="#" />
        </p:submenu>
    </p:menubar>
</h:form>

menuCtrl 是一个会话 bean:

public class MenuCtrl {

final static Logger log = Logger.getLogger(MenuCtrl.class);

private Submenu boxSubMenu;

public void setBoxSubMenu(Submenu boxSubMenu) {
    //this.boxSubMenu = boxSubMenu;
}

public Submenu getBoxSubMenu() {
    return boxSubMenu;
}

public MenuCtrl() {
    try {
        boxSubMenu = BoxMenuHelper.getBoxSubMenu();
    } catch (Exception ex) {            
        String msg = "Impossibile creare il menu di navigazione nei box";
        log.error(msg, ex);
        showMessage(FacesMessage.SEVERITY_ERROR, msg);
    }
}

}

子菜单工厂方法:

    public static Submenu getBoxSubMenu() throws Exception{
    CatalogazioneRepository br = new CatalogazioneRepository();
    Submenu sm = new Submenu();
    try {
        for (Catalogazione box : br.getOnlyBoxes()) {
            MenuItem item = new MenuItem();
            item.setId("boxMenuItem" + box.getId());
            item.setValue(box.getNome());
            item.setOnclick("navigateTo('Box/ListaRichieste.xhtml?box="+ box.getId() +"');");
            sm.getChildren().add(item);
        }
        return sm;
    } catch (Exception ex) {
        String msg = "Errore durante la creazione del menu di navigazione nei box";
        log.error(msg, ex);
        throw new Exception(msg, ex);
    }
}

【问题讨论】:

  • 确实很奇怪!有趣的是,这些问题似乎只发生在 IE9 上。您是否考虑过 IE9 可能会在 IE7 或 IE8 兼容模式下导航您的 Web 应用程序?我已经看到在兼容模式下运行的 IE 会导致 Primefaces 应用程序中出现奇怪的脚本错误和样式问题。默认情况下,本地 Intranet 区域中的任何站点都将默认以兼容模式运行,因此需要注意这一点。
  • @maple_shaft 啊,是的,几天前我们一直在努力反对的另一个有趣的行为。我的笔记本电脑 ie9 显示了 ie7 兼容模式的页面,这导致菜单与中心区域重叠(花费大量时间与 css 打架),而我的同事在正常的 ie9 模式下正确显示了它。现在我取消选中该选项
  • 是的,我非常讨厌 Internet Exploder :) ... 您可以选择升级到 Primefaces 3 吗?我刚开始使用 3.0 FINAL 版本,我对它非常满意。转换我的应用程序并不难,而且它比 2.2.1 更稳定。

标签: internet-explorer jsf-2 primefaces tomcat6


【解决方案1】:

我找到了这个Primefaces forum post

他们(optimus.prime - PrimeFaces 的创建者,而 Oleg 是论坛的高级用户)声称您应该将 menuitem 的构建器放在请求范围内,以避免奇怪的行为。

【讨论】:

    【解决方案2】:

    这篇文章有点老了,但是如果你有这样的用法,更喜欢属性; - 结果 - 网址

    只有在客户端操作中非常特殊的 java 脚本需要时才需要以下这种用法:

        <p:menuitem value="new requests" onclick="navigateTo('Richieste/ListaRichieste.xhtml?canale=0');" />
    

    首选以下选项:

        <p:menuitem value="new requests" url="Richieste/ListaRichieste.xhtml?canale=0"/>
    

        <p:menuitem value="new requests" outcome="Richieste/ListaRichieste?canale=0" />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多