使用 MenuModel 支持的菜单进行 Primefaces 布局导航

发布于 2024-12-22 07:57:58 字数 745 浏览 1 评论 0原文

使用 PrimeFaces,我想根据用户与包含在相同页面东部布局单元中的菜单(以编程方式创建的 MenuModel)的交互来更新/刷新页面中央布局单元。据我所知,这是不可能的,但很可能是错误的。谢谢!

subMenu = new Submenu();
subMenu.setLabel("Sales");  
subMenu.setIcon("ui-icon ui-icon-home");

-

private String currentPage; //holds identifier of current content panel

-

<!-- navigation panel -->
<p:layoutUnit position="west" resizable="false" size="216">
    <ui:include src="./includes/navigationMenu.xhtml" />
</p:layoutUnit>  

<!-- content panel -->
<p:layoutUnit position="center">
    <ui:include src="/views/#{navigationBean.currentPage}.xhtml" />         
</p:layoutUnit>

谢谢!

Using PrimeFaces, I want to update/refresh a pages central layout unit based on user interaction with a menu (programmatically created MenuModel) that's included in the same pages east layout unit. From what I can tell, this is not possible, but very well could be wrong. Thanks!

subMenu = new Submenu();
subMenu.setLabel("Sales");  
subMenu.setIcon("ui-icon ui-icon-home");

-

private String currentPage; //holds identifier of current content panel

-

<!-- navigation panel -->
<p:layoutUnit position="west" resizable="false" size="216">
    <ui:include src="./includes/navigationMenu.xhtml" />
</p:layoutUnit>  

<!-- content panel -->
<p:layoutUnit position="center">
    <ui:include src="/views/#{navigationBean.currentPage}.xhtml" />         
</p:layoutUnit>

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

深空失忆 2024-12-29 07:57:58

这只是一个问题:为什么要以编程方式创建菜单?

除此之外,几乎一切皆有可能:尝试将 ui:include 包含到具有 id 的表单组件中(比方说 myFormId),并尝试每次更新此表单选择子菜单项;好吧,让我们以编程方式做到这一点:

MenuItem item = new MenuItem();
item.setValue("Dynamic Menuitem");
item.setUrl("#");                    //add whatever attribute you want to menuItem
item.setUpdate("myFormId");
subMenu.getChildren().add(item);     //then add the menuItem object to subMenu as a child.

您可以在这里找到 menuItem API

It's just a question: Why do you create a menu programmatically?

Other than that almost everything it's possible: try to include the ui:include into a form component with an id (let's say myFormId) and try to update this form every time a submenu item is selected; Ok so let's do that programmatically:

MenuItem item = new MenuItem();
item.setValue("Dynamic Menuitem");
item.setUrl("#");                    //add whatever attribute you want to menuItem
item.setUpdate("myFormId");
subMenu.getChildren().add(item);     //then add the menuItem object to subMenu as a child.

You can find here the menuItem API

浅唱々樱花落 2024-12-29 07:57:58

我实现了一个侦听器..

MenuItem thisItem = (MenuItem)event.getComponent();
String navigateTo = thisItem.getId();
BeanManager beanManager = new BeanManager();
NavigationBean navBean = (NavigationBean)beanManager.get("navigationBean");
navBean.setCurrentPage(navigateTo);

将其添加到 MenuItem 以及对模板刷新()的调用...

item.addActionListener(new MenuItemListener());
item.setOnsuccess("refresh()");

添加了刷新方法...

function refresh(){
    document.location="#{request.contextPath}/faces/views/main.xhtml";
}

我真的不喜欢这个解决方案,但它比替代方案更好,标记中具有无法测试的菜单创建逻辑。

I implemented a listener..

MenuItem thisItem = (MenuItem)event.getComponent();
String navigateTo = thisItem.getId();
BeanManager beanManager = new BeanManager();
NavigationBean navBean = (NavigationBean)beanManager.get("navigationBean");
navBean.setCurrentPage(navigateTo);

added it to the MenuItem as well as a call to the the templates refresh()...

item.addActionListener(new MenuItemListener());
item.setOnsuccess("refresh()");

added the refresh method...

function refresh(){
    document.location="#{request.contextPath}/faces/views/main.xhtml";
}

I really don't care for this solution, but it's better than the alternative, having untestable menu creation logic in markup.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文