未考虑 subMenu 上的扩展属性 [英] expanded attribute on subMenu not taken into account

查看:47
本文介绍了未考虑 subMenu 上的扩展属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个面板菜单,里面有一些子菜单,其扩展属性由支持 bean 控制.问题是,不同子菜单的扩展状态似乎被浏览器缓存,这取决于用户上次访问该 url 时每个子菜单的先前状态,忽略设置为扩展的布尔状态.行为与 p:panelMenu 和 p:menu 相同.

I have a panelMenu with some submenus inside whose expanded attribute is controlled on a backing bean. The issue is, the expanded status of the different submenus seems to be cached by the browser, depending on the previous status of each submenu the previous time the user was on that url, ignoring the boolean status set to expanded. The behaviour is the same with p:panelMenu and with p:menu.

您可以在 PF 项目上重现该问题,将以下代码添加到 jsf 页面.不需要支持 bean.第一次加载页面时,中间的子菜单将显示为折叠状态.如果页面重新加载,在菜单上播放一下后,不再考虑扩展属性,页面显示方式响应用户在浏览器上的最后配置.

You can reproduce the issue on a PF project, adding the following code to a jsf page. No backing bean required. The first time the page is loaded, the submenu in the middle will appear as collapsed. After playing a bit with the menu if the page is reloaded, the expanded attribute is not taken into account anymore, and the way the page is display responds to the last configuration the user had on the browser.

<h:form>
    <p:panelMenu toggleable="true">
        <p:submenu label="No expandido" expanded="false">
            <p:menuitem value="External" url="http://www.primefaces.org"/>
        </p:submenu>
        <p:submenu label="Expandido" expanded="true">
            <p:menuitem value="External" url="http://www.primefaces.org"/>
        </p:submenu>
        <p:submenu label="No expandido" expanded="false">
            <p:menuitem value="External" url="http://www.primefaces.org"/>
        </p:submenu>
    </p:panelMenu>
</h:form>

注意手册,这种行为不是预期的:

Attending to the manual, this behaviour is not the expected one:

           expanded - false - Boolean - Defines the state of submenu.

...根据 Cagatay 在 PF 论坛上的帖子,panelMenu 已经准备好使用扩展属性.

... and according to a post by Cagatay in the PF forum, panelMenu is already ready to use the expanded attribute.

问题是,我有没有办法设置 panelMenu 或菜单内 subMenu 元素的展开/未展开状态?

感谢您的任何评论/建议/解决方法.

Thanks for any comment/suggestion/workaround.

Primefaces 5.2 |Tomcat 7.0.X |铬 + IE11

Primefaces 5.2 | Tomcat 7.0.X | Chrome + IE11

推荐答案

有没有试过设置 panelMenu 的 stateful 属性:

Have you tried setting the stateful attribute of the panelMenu:

<p:panelMenu stateful="false">

这会禁止将菜单缓存到 cookie.

This disables the menu from being cache to a cookie.

这篇关于未考虑 subMenu 上的扩展属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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