Primefaces 3.4 p:panelMenu:无法控制p:submenu和p:menuitem的状态

编程入门 行业动态 更新时间:2024-10-25 14:30:24
本文介绍了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设置/创建的(请参见 js for panelmenu ),并由Primefaces读取以更新其菜单. Cookie设置为保存用户已打开的子菜单项的ID.

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.

问题的解决方案是:

  • 确保仅存在具有用户指定ID的cookie
  • 确保菜单项中的所有请求都仅进入一个应用程序目录
  • 更多推荐

    Primefaces 3.4 p:panelMenu:无法控制p:submenu和p:menuitem的状态

    本文发布于:2023-10-24 08:52:44,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1523493.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:状态   Primefaces   panelMenu   menuitem   submenu

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!