Primefaces页面布局与树状菜单作为导航 [英] Primefaces page layout with tree menu as navigation

查看:530
本文介绍了Primefaces页面布局与树状菜单作为导航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用带有`的primefaces 3.1,有四个位置。
在西部位置(西)我添加了树状菜单。 JSF代码如下

I am using primefaces 3.1 with `, having four positions. In the west position(west) I have added tree menu. JSF code is follows

<p:layoutUnit position="west" size="200" header="Left"
            resizable="true" collapsible="true">
            <h:form>
                <p:tree dynamic="true" value="#{treeBean.root}" var="node" id="tree"
                    selectionMode="single">
                    <p:treeNode id="treeNode">
                        <h:outputText value="#{node}" id="lblNode" />
                    </p:treeNode>
                </p:tree>
            </h:form>
        </p:layoutUnit>

在TreeBean中我有

and in the TreeBean I have

root = new DefaultTreeNode("Root", null);  
        TreeNode node0 = new DefaultTreeNode("Color", root);  


        TreeNode node00 = new DefaultTreeNode("Red", node0);  
        TreeNode node01 = new DefaultTreeNode("Blue", node0);
        TreeNode node02 = new DefaultTreeNode("Green", node0);

当我展开并单击其中一个节点并单击相应节点时,是否可以进行导航?我可以在布局的中心位置显示jsf页面。即如果我点击节点蓝色,理想情况下我想将另一个jsf页面加载到布局的中心位置。

Is it possible to have navigation when I expand and click one of those nodes and upon clicking respective nodes how could I display jsf pages in the center position of layout. i.e. if I click node Blue, ideally I would like to have another jsf page being loaded into the center position of layout.

任何帮助都非常明显。

谢谢

更新1

我添加了以下代码,它导航到start.xhtml。但是start.xhtml不在我的布局中显示,start.xhtml显示为新页面。

I have added the following code and it does a navigation to start.xhtml. However start.xhtml is displayed not inside my layout, start.xhtml is displayed as a new page.

public void onNodeSelect(NodeSelectEvent event) {

        try {
            System.out.println(" here " + event.getTreeNode().getData());
            FacesContext
                    .getCurrentInstance()
                    .getApplication()
                    .getNavigationHandler()
                    .handleNavigation(FacesContext.getCurrentInstance(),
                            "null", "/start.xhtml?faces-redirect=true");
        } catch (Exception e) {
            logger.info("error "+e.getMessage());
            // TODO: handle exception
        } 


推荐答案

我认为这篇文章对你非常有用在另一个JSF中加入一个xhtml

I think that this post will be very useful for you Include one xhtml inside another JSF

它描述了如何创建模板,然后在模板客户端中使用它。 @rags已经告诉过你了,但你真的不必使用< p:layout> 。上面链接的文章更准确。我相信你会在那里找到你需要的东西。问候

It describes how you create a template and then use it in your template client. @rags already told you that, but you don't really have to use <p:layout>. Article linked above is just more precise. I believe you will find what you need there. Regards

这篇关于Primefaces页面布局与树状菜单作为导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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