1

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

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 标记:

     <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>

这是日志:

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

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

ķ

4

1 回答 1

0

我找到了解决方案。代码没有任何问题,问题在于命名标签面板的标记。由于选项卡面板位于 TabbedPanelPage 类中,因此标记将按照相应的方式命名。

例如。

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

干杯

于 2014-12-18T07:42:15.150 回答