Forms 如何在Wicket中的表单上实现后退按钮支持?

Forms 如何在Wicket中的表单上实现后退按钮支持?,forms,wicket,back-button,Forms,Wicket,Back Button,我有一个带有选项卡式面板的搜索页面,每个选项卡内都有一个表单(请参见下面的代码),提交时会搜索数据库中的点击量。但是,此表单上的后退按钮支持不起作用(textField中用户提供的文本丢失)。如何实现此表单的后退按钮支持?我一直在尝试在页面、面板、表单和textField上发布setVersioned(true),并在textField和表单上发布modelChanging()和modelChanged(),但这些都不起作用。我也尝试过从TabbedPanel中重写方法newLink,但这也不起

我有一个带有选项卡式面板的搜索页面,每个选项卡内都有一个表单(请参见下面的代码),提交时会搜索数据库中的点击量。但是,此表单上的后退按钮支持不起作用(textField中用户提供的文本丢失)。如何实现此表单的后退按钮支持?我一直在尝试在页面、面板、表单和textField上发布setVersioned(true),并在textField和表单上发布modelChanging()和modelChanged(),但这些都不起作用。我也尝试过从TabbedPanel中重写方法newLink,但这也不起作用。我不知所措

任何帮助都将不胜感激

public class TextSearchPanel extends Panel {
    CompoundsDataTablePanel hitsPanel;

    @SpringBean
    ICompoundDAO            compoundDAO;

    public TextSearchPanel(final String id, final FeedbackPanelWrapper feedbackPanel) {
        super(id);
        setOutputMarkupId(true);

        // Text Search Form
        Form<TextSearchPanel> textform = new Form<TextSearchPanel>("textForm");

        // Add textField
        TextField<String> textField = new TextField<String>("query", new Model<String>());
        textField.setRequired(true);
        textField.add(new StringValidator() {
            @Override
            protected void onValidate(final IValidatable<String> validatable) {
                String query = Name.replaceApostropheVariantsWithApostrophe(validatable.getValue());
                try {
                    // Ascertain parsing query does not throw an exception
                    compoundDAO.parseQuery(query);
                }
                catch (ParseException e) {
                    // Otherwise: Display the error back to the user
                    validatable.error(new ValidationError().setMessage(e.getMessage()));
                }
            }
        });
        textform.add(textField);

        // Add submit button
        textform.add(new IndicatingAjaxButton("ajaxsubmit") {
            @Override
            protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
                target.addComponent(feedbackPanel);
                // Show hits panel
                hitsPanel.setVisible(true);
                target.addComponent(TextSearchPanel.this);
            }

            @Override
            protected void onError(final AjaxRequestTarget target, final Form<?> form) {
                target.addComponent(feedbackPanel);
                // Hide hits panel
                hitsPanel.setVisible(false);
                target.addComponent(TextSearchPanel.this);
            }
        });
        add(textform);

        // Text Hits Panel
        hitsPanel = new CompoundsDataTablePanel("hits", new TextHitsProvider(textField.getModel()));
        hitsPanel.setVisible(false);
        add(hitsPanel);
    }
}
公共类文本搜索面板扩展面板{
复合可更换面板hitsPanel;
@春豆
i复合道复合道;
公共文本搜索面板(最终字符串id、最终反馈面板包装器反馈面板){
超级(id);
setOutputMarkupId(真);
//文本搜索表单
表格textform=新表格(“textform”);
//添加文本字段
TextField TextField=newtextfield(“查询”,newmodel());
textField.setRequired(true);
添加(新的StringValidator(){
@凌驾
受保护的void onValidate(最终可验证){
String query=Name.replaceAsstorpheVariantswithApostrophe(validatable.getValue());
试一试{
//确定解析查询不会引发异常
parseQuery(查询);
}
捕获(解析异常){
//否则:将错误显示回用户
validatable.error(新的ValidationError().setMessage(e.getMessage()));
}
}
});
textform.add(textField);
//添加提交按钮
textform.add(新的指示按钮(“ajaxsubmit”){
@凌驾
提交时受保护的void(最终AjaxRequestTarget目标,最终表单){
target.addComponent(反馈面板);
//显示点击面板
hitsPanel.setVisible(真);
target.addComponent(TextSearchPanel.this);
}
@凌驾
受保护的void onError(最终AjaxRequestTarget目标,最终表单){
target.addComponent(反馈面板);
//隐藏点击面板
hitsPanel.setVisible(假);
target.addComponent(TextSearchPanel.this);
}
});
添加(文本格式);
//文本点击面板
hitsPanel=newcompoundsdatatablepanel(“hits”,新文本hitsprovider(textField.getModel());
hitsPanel.setVisible(假);
添加(hitsPanel);
}
}
页面类别:

public class SearchPage extends BasePage {
public SearchPage() {
    super("Search");
    setOutputMarkupId(true);

    List<ITab> tabs = new ArrayList<ITab>();
    tabs.add(new AbstractTab(new Model<String>("Spectrum search")) {
        @Override
        public Panel getPanel(final String panelId) {
            return new SpectrumSearchPanel(panelId, getFeedbackPanelWrapper());
        }
    });
    tabs.add(new AbstractTab(new Model<String>("Mass search")) {
        @Override
        public Panel getPanel(final String panelId) {
            return new MassSearchPanel(panelId, getFeedbackPanelWrapper());
        }
    });
    tabs.add(new AbstractTab(new Model<String>("Formula search")) {
        @Override
        public Panel getPanel(final String panelId) {
            return new FormulaSearchPanel(panelId, getFeedbackPanelWrapper());
        }
    });
    tabs.add(new AbstractTab(new Model<String>("Text search")) {
        @Override
        public Panel getPanel(final String panelId) {
            return new TextSearchPanel(panelId, getFeedbackPanelWrapper());
        }
    });

    // Add tabs to page to switch between search modes
    add(new TabbedPanel("tabs", tabs));
}
 }
公共类搜索页面扩展了BasePage{
公共搜索页(){
超级搜索;
setOutputMarkupId(真);
列表选项卡=新建ArrayList();
添加(新的抽象选项卡(新模型(“频谱搜索”)){
@凌驾
公共面板getPanel(最终字符串panelId){
返回新的SpectrumSearchPanel(panelId,getFeedbackPanelWrapper());
}
});
添加(新的抽象选项卡(新模型(“批量搜索”)){
@凌驾
公共面板getPanel(最终字符串panelId){
返回新的MassSearchPanel(panelId,getFeedbackPanelWrapper());
}
});
tabs.add(新抽象选项卡(新模型(“公式搜索”)){
@凌驾
公共面板getPanel(最终字符串panelId){
返回新的FormulaSearchPanel(panelId,getFeedbackPanelWrapper());
}
});
添加(新抽象选项卡(新模型(“文本搜索”)){
@凌驾
公共面板getPanel(最终字符串panelId){
返回新的TextSearchPanel(panelId,getFeedbackPanelWrapper());
}
});
//将选项卡添加到页面以在搜索模式之间切换
添加(新选项卡床面板(“选项卡”,选项卡));
}
}

我还没有机会尝试您的代码,但是使用ajax可能会有问题。wicket中的ajax尚未完全支持后退按钮:。与第一次查看页面相比,按“上一步”按钮时,您可能需要检查正在查看的页面的版本。

谢谢!事实上,问题在于指示按钮。我用html中的常规submit按钮替换了它,并在表单中添加了submit和onError的覆盖方法,以调节结果面板何时可见。它现在起作用了。