0

我将我的应用程序从 Wicket 6.x 升级到 Wicket 8.x,并将ButtonAjaxButton类替换为IndicatingAjaxButton类。单击提交按钮链接时出现以下错误。

IndicatingAjaxButton btnSubmit = new IndicatingAjaxButton("submit") {
        private static final long serialVersionUID = 1L;
        @SuppressWarnings("rawtypes")
        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            AjaxLazyLoadPanel panel = new AjaxLazyLoadPanel("cnt2") {
                private static final long serialVersionUID = 1L;
                @Override
                public Component getLazyLoadComponent(String markupId) {
                    try {
                        return new ContractClassPanel(markupId, null, getIdentifier(), getTimelines());
                    } catch (ContractException e) {
                        throw new RuntimeException("", e);
                    }
                }
            };
            panel.setOutputMarkupId(true);
            form.setVisible(false);
            AbstractContractsClassPage.this.replace(panel);
            target.focusComponent(AbstractContractsClassPage.this);
        }
        @Override
        protected void onError(AjaxRequestTarget target) {
            super.onError();
        }           
    };

错误 | 发生异常:org.apache.wicket.core.request.handler.ListenerInvocationNotAllowedException:行为拒绝接口调用。组件:[AjaxButton [Component id = submit]] 行为:org.apache.wicket.ajax.markup.html.form.AjaxButton$1@591549f6 at org.apache.wicket.core.request.handler.ListenerRequestHandler.invoke(ListenerRequestHandler. java:276) 在 org.apache.wicket.core.request.handler.ListenerRequestHandler.invokeListener(ListenerRequestHandler.java:222) 在 org.apache.wicket.core.request.handler.ListenerRequestHandler.respond(ListenerRequestHandler.java:208)在 org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:914) 在 org.apache.wicket.request.RequestHandlerExecutor.execute(RequestHandlerExecutor.java:65) 在 org.apache.wicket.request .cycle.RequestCycle.execute(RequestCycle.java:

4

1 回答 1

0

我错过了在表单中添加当前类 (AbstractContractsClassPage.this) 的代码。而且我调用了错误的方法focusComponent() 而不是add()。

我在调用 add() 方法而不是 focusComponent() 后得到了解决方案。

        protected void onSubmit(AjaxRequestTarget target) {
            AjaxLazyLoadPanel panel = new AjaxLazyLoadPanel("cnt2") {
                private static final long serialVersionUID = 1L;
                @Override
                public Component getLazyLoadComponent(String markupId) {
                    try {
                        return new ContractClassPanel(markupId, null, getIdentifier(), getTimelines());
                    } catch (ContractException e) {
                        throw new RuntimeException("", e);
                    }
                }
            };
            panel.setOutputMarkupId(true);
            form.setVisible(false);
            AbstractContractsClassPage.this.replace(panel);
            **target.add(AbstractContractsClassPage.this);**
        }
        
于 2020-11-02T20:10:19.093 回答