icefaces 之 顶层菜单

来源:互联网 发布:广告公司软件 编辑:程序博客网 时间:2024/06/10 04:53

   在web 开发中顶层菜单是很重要的

 

    下面是一个很简单的顶层菜单,是动态的

 

     前台代码:

 

        <?xml version="1.0" encoding="UTF-8"?>
<!--
    Document   : Page1
    Created on : 2009-4-20, 11:20:56
    Author     : bolink
-->
<jsp:root version="2.0" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:ice="http://www.icesoft.com/icefaces/component">
    <jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
    <f:view>
            <html id="outputHtml1">
                <head id="outputHead1">
                    <ice:outputStyle id="outputStyle1" href="./resources/stylesheet.css"/>
                    <ice:outputStyle id="outputStyle2" href="./xmlhttp/css/xp/xp.css"/>
                </head>
                <body id="outputBody1" style="-rave-layout: grid">
                    <ice:form id="form1">
                       <ice:menuBar orientation="horizontal">

                        <ice:menuItem value="首页" />
                        <ice:menuItems actionListener="#{MenuBean.menuBar}" value="#{MenuBean.menuModel}"/>
                        <ice:menuItem value="关于">
                            <ice:menuItem  value="公司简介" />
                            <ice:menuItem value="联系我们" />
                        </ice:menuItem>
                    </ice:menuBar>
                    </ice:form>
                </body>
            </html>
    </f:view>
</jsp:root>

 


后台对应的 java 代码:

 

   public class MenuBean extends AbstractPageBean {
    // <editor-fold defaultstate="collapsed" desc="Managed Component Definition">
    private int __placeholder;

    /**
     * <p>Automatically managed component initialization.  <strong>WARNING:</strong>
     * This method is automatically generated, so any user-specified code inserted
     * here is subject to being replaced.</p>
     */
    private void _init() throws Exception {
    }

    // </editor-fold>

    /**
     *  @auto bolink
     */
    private List menuModel;
    public List getMenuModel() {
        return menuModel;
    }
    public MenuBean() {
        menuModel = new ArrayList();

        MenuItem topLevel1 = new MenuItem();
        topLevel1.setValue("角色管理");

        MenuItem topLevel2 = new MenuItem();
        topLevel2.setValue("员工管理");

        MenuItem topLevel3 = new MenuItem();
        topLevel3.setValue("部门管理");

        menuModel.add(topLevel1);
        menuModel.add(topLevel2);
        menuModel.add(topLevel3);

        MenuItem sub1_1 = new MenuItem();
        sub1_1.setValue("sub1_1");
        MenuItem sub1_2 = new MenuItem();
        sub1_2.setValue("sub1_2");
        MenuItem sub1_3 = new MenuItem();
        sub1_3.setValue("sub1_3");

        topLevel1.getChildren().add(sub1_1);
        topLevel1.getChildren().add(sub1_2);
        topLevel1.getChildren().add(sub1_3);
    }

    public void init() {
        super.init();
    }

    public void preprocess() {
    }

    public void prerender() {
    }
    public void destroy() {
    }
}

 

 一个很简单的顶层菜单,测试用的代码。呵~

原创粉丝点击