使用Hibernate

时间:2017-09-08 13:55:56

标签: java mysql hibernate wicket

所以我一直在尝试从我的数据库中显示文本作为Apache Wicket中向导的内容,但是被“TextFromDatabase”类的构造函数所困扰,以及如何使数据可用于我的Wizard类。这是GitHub repository

我正在从我的输入表单中将数据保存到我的MySQL数据库,只是无法让它在我的向导中呈现。我已经在下面包含了我的“StaticWizard”类的片段以及它给出的错误消息。到目前为止我一直在使用的资源是: [An example wizard for file uploads] [the original static wizard] [the Acknowledgement class in an app with working persistence]

    package com.javaonline;

    import org.apache.wicket.extensions.wizard.StaticContentStep;
    import org.apache.wicket.extensions.wizard.Wizard;
    import org.apache.wicket.extensions.wizard.WizardModel;
    import org.apache.wicket.markup.html.WebPage;
    import org.apache.wicket.markup.html.basic.Label;
    import org.apache.wicket.model.IModel;
    import org.apache.wicket.request.mapper.parameter.PageParameters;

    public class StaticWizard extends Wizard {
        public StaticWizard(String id) {
            super(id);

            TextFromDatabase data = new TextFromDatabase();

            WizardModel model = new WizardModel();
            model.add(new StaticContentStep("One", "The first step", data.answer_a, true));
            model.add(new StaticContentStep("Two", "The second step", data.answer_b, true));
            model.add(new StaticContentStep("Three", "The third step", data.answer_c, true));       

            init(model);
        }

        public class TextFromDatabase extends WebPage {
            public TextFromDatabase(final PageParameters page) throws Exception {

                Label answer_a = new Label("answer_a", page.get("answer_a"));
                Label answer_b = new Label("answer_b", page.get("answer_b"));
                Label answer_c = new Label("answer_c", page.get("answer_c"));

                add(answer_a);
                add(answer_b);
                add(answer_c);
            }
        }

        @Override
        public void onCancel() {
            setResponsePage(RegistrationInputPage.class);
        }

        @Override
        public void onFinish() {
            setResponsePage(RegistrationInputPage.class);
        }

    }

导致错误消息:

Last cause: Unresolved compilation problems: 
The constructor StaticWizard.TextFromDatabase() is undefined
anser_a cannot be resolved or is not a field
anser_b cannot be resolved or is not a field
anser_c cannot be resolved or is not a field

WicketMessage: Method onLinkClicked of interface 
org.apache.wicket.markup.html.link.ILinkListener targeted at 
[WizardLink [Component id = staticWizardLink]] on component [WizardLink 
[Component id = staticWizardLink]] threw an exception

0 个答案:

没有答案