给出以下折叠菜单(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”似乎没有固定的规则。
我不知道原因。我主要在所有视图中使用重定向(“faces-redirect = true”),而一些视图包含复合元素
有人有提示吗?
环境:
答案 0 :(得分:6)
primeFaces的panelMenu需要保存其状态,以便始终向用户显示之前已打开/关闭的子菜单。 PanelMenu使用名称为panelmenu本身ID的cookie在客户端保存状态。使用javascript(见js for panelmenu)由cliend方设置/创建cookie,并由Primefaces读取以更新其菜单。 cookie被设置为保存用户已打开的子菜单项的ID。
解决问题的方法是:答案 1 :(得分:0)
你可以这样做,你需要把它放在组件stateful="true"
上
并在itemMenu中设置ajax=false
async=false
global=false
partialSubmit=false
resetValue=false
immediate=true
。
那就是它。