Primefaces 3.4 p:panelMenu:无法控制p:submenu和p:menuitem的状态 [英] Primefaces 3.4 p:panelMenu: unable to control the state of p:submenu and p:menuitem

查看:128
本文介绍了Primefaces 3.4 p:panelMenu:无法控制p:submenu和p:menuitem的状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出以下折叠菜单(p:panelMenu):

Given the following collapsing Menu (p:panelMenu):

<p:panelMenu style="width:200px">
            <p:submenu label="#{uimsg.clm_title}" styleClass="pageFont">
                <!--                <p:menuitem value="Delete" actionListener="#{buttonBean.delete}"  ajax="true" icon="ui-icon-close"/>   -->
            </p:submenu>
            <p:separator />

            <!-- Sub-menu master Data  -->
            <p:submenu label="#{uimsg.trsf_title}" styleClass="pageFont">
                <p:menuitem value="#{uimsg.trsf_create}" ajax="true"
                    icon="ui-icon-arrow-1-e" url="/transfers/editTransfer.xhtml" />
            </p:submenu>
            <p:separator />


            <!-- Sub-menu master Data  -->
            <p:submenu label="#{uimsg.mst_data_title}" styleClass="pageFont">

                <!--  Clubs -->
                <p:submenu label="#{uimsg.mst_data_club_title}">
                    <p:menuitem value="#{uimsg.mst_data_show_club_title}" ajax="true"
                        icon="ui-icon-arrow-1-e" url="/clubs/showClubs.xhtml" />

                    <p:menuitem value="#{uimsg.mst_data_edit_club_title}" ajax="true"
                        icon="ui-icon-arrow-1-e" url="/clubs/editClub.xhtml" />
                </p:submenu>


                <!--  Associations -->
                <p:submenu label="#{uimsg.mst_data_assocation_title}">
                    <p:menuitem value="#{uimsg.mst_data_show_association_title}"
                        ajax="true" icon="ui-icon-arrow-1-e"
                        url="/associations/showAssociations.xhtml" />

                    <p:menuitem value="#{uimsg.mst_data_edit_association_title}"
                        ajax="true" icon="ui-icon-arrow-1-e"
                        url="/associations/editAssociation.xhtml" />
                </p:submenu>

                <!-- leagues -->
                <p:submenu label="#{uimsg.mst_data_league_title}">

                    <p:menuitem value="#{uimsg.mst_data_show_league_title}"
                        icon="ui-icon-arrow-1-e" url="/league/showLeagues.xhtml" ajax="true"/>

                    <p:menuitem value="#{uimsg.mst_data_edit_league_title}"
                        icon="ui-icon-arrow-1-e" url="/league/editLeague.xhtml" ajax="true"/>
                </p:submenu>

                <!-- Players -->
                <p:submenu label="#{uimsg.mst_data_player_title}">

                    <p:menuitem value="#{uimsg.player_menu_show}" ajax="true"
                        icon="ui-icon-arrow-1-e" url="/player/showPlayers.xhtml" />

                    <p:menuitem value="#{uimsg.player_menu_edit}" ajax="true"
                        icon="ui-icon-arrow-1-e" url="/player/editPlayer.xhtml" />

                </p:submenu>

                <!-- Confederation -->
                <p:submenu label="#{uimsg.mst_data_confed_title}">

                    <p:menuitem value="#{uimsg.mst_data_edit_confed_title}"
                        icon="ui-icon-arrow-1-e"
                        url="/confederations/showConfederations.xhtml" ajax="true" />

                    <p:menuitem value="#{uimsg.mst_data_show_confed_title}"
                        icon="ui-icon-arrow-1-e"
                        url="/confederations/editConfederation.xhtml" ajax="true" />

                </p:submenu>

            </p:submenu>

            <p:separator />

            <!-- Sub-menu Administration -->

            <p:submenu label="#{uimsg.admin_title}"
                rendered="#{auth.showAdministration() == true ? true : false }"
                id="adminDivId" styleClass="pageFont">
                <!-- User menu -->
                <p:submenu label="#{uimsg.users_admin_title}">
                    <p:menuitem value="#{uimsg.admin_show_users_title}" ajax="true"
                        icon="ui-icon-arrow-1-e" url="/users/showUsers.xhtml" />
                    <p:menuitem value="#{uimsg.admin_edit_users_title}" ajax="true"
                        icon="ui-icon-arrow-1-e" url="/users/editUser.xhtml"
                        disabled="#{auth.editUsers() == true ? false : true }" />
                </p:submenu>

                <!-- Role menu -->
                <p:submenu label="#{uimsg.roles_admin_title}">
                    <p:menuitem value="#{uimsg.admin_show_role_title}" ajax="true"
                        icon="ui-icon-arrow-1-e" url="/roles/showRoles.xhtml" />
                    <p:menuitem value="#{uimsg.admin_edit_role_title}" ajax="true"
                        icon="ui-icon-arrow-1-e" url="/roles/editRole.xhtml"
                        disabled="#{auth.editUsers() ne true}" />
                </p:submenu>
            </p:submenu>

            <p:separator />
            <!-- Sub-menu Version -->
            <p:submenu label="#{uimsg.abt_software_title}" styleClass="pageFont">
                <p:menuitem value="#{uimsg.abt_software_show_informations}"
                    icon="ui-icon-arrow-1-e" url="/version/showVersion.xhtml" ajax="true"/>
            </p:submenu>
</p:panelMenu>

每次单击menuItem时,PanelMenu的行为都非常奇怪且不可预测:有些subMenu折叠了,而另一些则没有.这个"jabbi-jabba"似乎没有固定的规则.

By each click on a menuItem, the PanelMenu behaves very strangely and und unpredictablely: some subMenu's collapsed and other don't. there seems to be no fixed rules for this "jabbi-jabba".

我不知道原因.我主要在所有视图中使用重定向("faces-redirect = true"),并且某些视图包含复合元素

i don't know the cause of this. I used mainly redirection in all views ("faces-redirect=true") and some views contain composite elements

有人暗示吗?

环境:

  • AS:JBoss 7.1.1最终版
  • JSF版本:2.1.13
  • Primefaces:3.4.1

推荐答案

primaryFaces的panelMenu需要保存其状态,以便它始终可以向用户显示先前已打开/关闭的子菜单. PanelMenu使用一个名为panelmenu本身的ID的cookie,将其状态保存在客户端. Cookie是由客户端使用javascript设置/创建的(请参见

The panelMenu of primeFaces needs to save its state so that it can always show the user which submenus have been opened/closed previously. PanelMenu saves it state at the client side , using a cookie having as name the id of the panelmenu itself. The cookie is set/created by the cliend side using javascript (see js for panelmenu) and is read by Primefaces to update its menu. The cookie is set to hold the id of submenu items that have been opened by the user.

问题的解决方案是:

  1. 确保仅存在具有用户指定ID的cookie
  2. 确保菜单项中的所有请求都仅进入一个应用程序目录

这篇关于Primefaces 3.4 p:panelMenu:无法控制p:submenu和p:menuitem的状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆