Apache Isis:如何获取添加的自定义窗口组件的值

时间:2017-02-22 08:27:45

标签: java wicket isis

我对Apache ISIS很陌生,我试图通过扩展ScalarPanelAbstract来添加自定义wicket组件。

我有一个接受pageable参数的方法。 pageable是一个包含页码页面大小的界面。

//region > findAllWithPage (action)
    @Action(semantics = SemanticsOf.SAFE)
    public PagedList<Employee> findAllWithPage(
            @Parameter(optionality = Optionality.OPTIONAL)
            final Pageable pageable) {

        return employeeRepository.findByOwner(userTenancyService.owner(), pageable);
    }
//endregion

这是您使用操作findAllWithPage时的样子。它只有一个可分页的参数。

现在,我要做的是让它接受两个参数Page number and Page size

我的问题是,我无法获得两个文本字段的值。这是我得到的错误。

&#13;
&#13;
org.apache.wicket.WicketRuntimeException: Method onRequest of interface org.apache.wicket.behavior.IBehaviorListener targeted at org.apache.wicket.ajax.markup.html.form.AjaxButton$1@c6dc7e3 on component [AjaxButton [Component id = okButton]] threw an exception
	at org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:268)
	at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:241)
	at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.invokeListener(ListenerInterfaceRequestHandler.java:250)
	at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:236)
	at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:890)
	at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
	at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:261)
	at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:218)
	at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:289)
	at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:259)
	at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:201)
	at org.apache.wicket.protocol.http.WicketServlet.doPost(WicketServlet.java:159)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:821)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1685)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
	at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
	at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
	at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
	at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1668)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:581)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1158)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1090)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:119)
	at org.eclipse.jetty.server.Server.handle(Server.java:517)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:308)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:242)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:261)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
	at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:75)
	at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:213)
	at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:147)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:258)
	... 44 more
Caused by: java.lang.IllegalArgumentException: argument type mismatch
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionInvocationFacetForDomainEventAbstract.invokeMethodElseFromCache(ActionInvocationFacetForDomainEventAbstract.java:408)
	at org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionInvocationFacetForDomainEventAbstract$2.execute(ActionInvocationFacetForDomainEventAbstract.java:262)
	at org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionInvocationFacetForDomainEventAbstract$2.execute(ActionInvocationFacetForDomainEventAbstract.java:223)
	at org.apache.isis.applib.services.iactn.Interaction.executeInternal(Interaction.java:173)
	at org.apache.isis.applib.services.iactn.Interaction.execute(Interaction.java:143)
	at org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionInvocationFacetForDomainEventAbstract.doInvoke(ActionInvocationFacetForDomainEventAbstract.java:311)
	at org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionInvocationFacetForDomainEventAbstract$1.execute(ActionInvocationFacetForDomainEventAbstract.java:165)
	at org.apache.isis.core.runtime.system.transaction.IsisTransactionManager.executeWithinTransaction(IsisTransactionManager.java:143)
	at org.apache.isis.core.runtime.system.transaction.IsisTransactionManager.executeWithinTransaction(IsisTransactionManager.java:133)
	at org.apache.isis.core.runtime.services.persistsession.PersistenceSessionServiceInternalDefault.executeWithinTransaction(PersistenceSessionServiceInternalDefault.java:179)
	at org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionInvocationFacetForDomainEventAbstract.invoke(ActionInvocationFacetForDomainEventAbstract.java:161)
	at org.apache.isis.core.metamodel.specloader.specimpl.ObjectActionDefault.executeInternal(ObjectActionDefault.java:398)
	at org.apache.isis.core.metamodel.specloader.specimpl.ObjectActionDefault.execute(ObjectActionDefault.java:387)
	at org.apache.isis.core.metamodel.specloader.specimpl.ObjectActionDefault.executeWithRuleChecking(ObjectActionDefault.java:368)
	at org.apache.isis.viewer.wicket.model.models.ActionModel.executeAction(ActionModel.java:483)
	at org.apache.isis.viewer.wicket.model.models.ActionModel.load(ActionModel.java:462)
	at org.apache.isis.viewer.wicket.model.models.ActionModel.load(ActionModel.java:80)
	at org.apache.wicket.model.LoadableDetachableModel.getObject(LoadableDetachableModel.java:124)
	at org.apache.isis.viewer.wicket.model.models.ActionModel.executeHandlingApplicationExceptions(ActionModel.java:568)
	at org.apache.isis.viewer.wicket.ui.components.actions.ActionPanel.executeActionOnTargetAndProcessResults(ActionPanel.java:255)
	at org.apache.isis.viewer.wicket.ui.components.actions.ActionPanel.executeAndProcessResults(ActionPanel.java:204)
	at org.apache.isis.viewer.wicket.ui.components.actions.ActionParametersFormPanel$ActionParameterForm$1.onSubmit(ActionParametersFormPanel.java:148)
	at org.apache.wicket.ajax.markup.html.form.AjaxButton$1.onSubmit(AjaxButton.java:108)
	at org.apache.wicket.ajax.form.AjaxFormSubmitBehavior$AjaxFormSubmitter.onSubmit(AjaxFormSubmitBehavior.java:215)
	at org.apache.wicket.markup.html.form.Form.delegateSubmit(Form.java:1305)
	at org.apache.wicket.markup.html.form.Form.process(Form.java:966)
	at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:788)
	at org.apache.wicket.ajax.form.AjaxFormSubmitBehavior.onEvent(AjaxFormSubmitBehavior.java:171)
	at org.apache.wicket.ajax.AjaxEventBehavior.respond(AjaxEventBehavior.java:146)
	at org.apache.wicket.ajax.AbstractDefaultAjaxBehavior.onRequest(AbstractDefaultAjaxBehavior.java:641)
	... 49 more
&#13;
&#13;
&#13;

HMTL:

&#13;
&#13;
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns:wicket="http://wicket.apache.org">
    <body>
        <wicket:panel>
            <div class="PageablePanel scalarNameAndValueComponentType">
                <div class="form-group" wicket:id="scalarIfRegular">
                    <label wicket:id="scalarName" class="scalarName control-label mandatory">[Label text]</label>
                    <span class="scalarValueWrapper">
                        <span class="uploadFile help-block">
                           <input type="text" class="form-control input-sm" name="scalarValue" wicket:id="scalarValue" />
                        </span>
                    </span>

                    <label wicket:id="scalarName1" class="scalarName control-label mandatory">[Label text]</label>
                    <span class="scalarValueWrapper">
                        <span class="uploadFile help-block">
                           <input type="text" class="form-control input-sm" name="scalarValue1" wicket:id="scalarValue1" />
                        </span>
                        <a wicket:id="scalarIfRegularClear" class="btn btn-primary btn-sm"><span class="clearTitle">Clear</span></a>
                        <span wicket:id="feedback" class="help-block"></span>
                        <span wicket:id="associatedActionLinksBelow"></span>
                    </span>
                    <span wicket:id="associatedActionLinksRight"></span>
                </div>
                <span wicket:id="scalarIfCompact"> </span>
            </div>
        </wicket:panel>
    </body>
</html>
&#13;
&#13;
&#13;

在扩展PageablePanelAbstract.java的{​​{1}}上,有三种方法被覆盖:

  • ScalarPanelAbstract
  • addComponentForRegular();
  • addComponentForCompact();

PageablePanelAbstract.java

&#13;
&#13;
addFormComponentBehavior();
&#13;
&#13;
&#13;

我可以操纵哪些方法来获取两个文本字段的值?感谢。

0 个答案:

没有答案