标签式面板页面:

时间:2014-11-28 08:35:03

标签: html wicket-6

我正在尝试在wicket中实现选项卡式面板页面的示例,但它不起作用。我已经剥离了一些我认为对我当前场景不必要的方法。我不确定我是否错过了什么。请建议。

TabbedPanelPage Java:

 public class TabbedPanelPage extends WebPage {
            Logger log = Logger.getLogger(TabbedPanelPage.class);
            private static final long serialVersionUID = 1L;

            public TabbedPanelPage() {
                    setDefaultModel(new Model<String>("tabpanel"));
                    log.info("Constructor: ");
                    List<ITab> tabs = new ArrayList<ITab>();
                    log.info("AbstractTab : 1");
                    tabs.add(new AbstractTab(new Model<String>("first tab")) {
                            private static final long serialVersionUID = 1L;

                            @Override
                            public Panel getPanel(String panelId) {
                                    log.info("getPanel: 1");
                                    return new TabPanel1(panelId);
                            }

                    });
                    log.info("AbstractTab : 2");
                    tabs.add(new AbstractTab(new Model<String>("second tab")) {
                            private static final long serialVersionUID = 1L;

                            @Override
                            public Panel getPanel(String panelId) {
                                    log.info("getPanel: 2");
                                    return new TabPanel2(panelId);
                            }

                    });
                    log.info("AbstractTab : 3");
                    tabs.add(new AbstractTab(new Model<String>("third tab")) {
                            private static final long serialVersionUID = 1L;

                            @Override
                            public Panel getPanel(String panelId) {
                                    log.info("getPanel: 3");
                                    return new TabPanel3(panelId);
                            }

                    });

                    add(new TabbedPanel("tabs", tabs));

            }

            private static class TabPanel1 extends Panel {
                    private static final long serialVersionUID = 1L;
                    Logger log = Logger.getLogger(TabPanel1.class);

                    public TabPanel1(String id) {
                            super(id);
                            log.info("TabPanel1");
                    }

            }

            private static class TabPanel2 extends Panel {
                    private static final long serialVersionUID = 1L;
                    Logger log = Logger.getLogger(TabPanel2.class);

                    public TabPanel2(String id) {
                            super(id);
                            log.info("TabPanel1");
                    }

            }

            private static class TabPanel3 extends Panel {
                    private static final long serialVersionUID = 1L;
                    Logger log = Logger.getLogger(TabPanel3.class);

                    public TabPanel3(String id) {
                            super(id);
                            log.info("TabPanel1");
                    }

            }
    }

TabbedPanelPage Mark-Up:

     <html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
        <head>
        <title>Wicket Examples - component reference</title>
        </head>
        <body>
            <div wicket:id="tabs">[tabbed panel will be here]</div>
        </body>
        </html>

TabPanel1标记:

    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
        <wicket:panel>
        <br />
        This is tab-panel 1
        </wicket:panel>
        </html>

这是Log:

  

构造函数:
      AbstractTab:1
      AbstractTab:2
      AbstractTab:3
      getPanel:1
    TabPanel1。

我的应用程序此时终止。 提前谢谢。

ķ

1 个答案:

答案 0 :(得分:0)

我找到了解决方案。代码没有任何问题,问题在于为tabpanel命名标记。由于tabpanel位于TabbedPanelPage类中,因此标记将按照命名进行命名。

例如

TabPanel1的标记页面必须是TabPanelPage $ TabPanel1.html

干杯