2014-10-27 59 views
1

禁用整體形成時,我有這種形式在檢票,其具有當與一定的作用的用戶在將被記錄到被禁用。異常在檢票

在我檢查角色的onConfigure()方法,和如果它是不允許更改任何一個我禁用表:

getForm().setEnabled(!isSponsor()); 

但後來,我得到這個錯誤:

org.apache.wicket.markup.MarkupException: file:/bla/bla/bla/Panel.html: Component [printButton] (path = [1:work:child:bla:7:bla:fieldContainer:field:modal:content:form:Panel:printButton]) must be applied to a tag of type [button,input,a], not: '<span wicket:id="printButton" id="printButtonb3">' (line 0, column 0) 
    at de.agilecoders.wicket.core.util.Components.createMarkupException(Components.java:96) ~[wicket-bootstrap-core-0.8.4.jar:?] 
    at de.agilecoders.wicket.core.util.Components.assertTag(Components.java:80) ~[wicket-bootstrap-core-0.8.4.jar:?] 
    at de.agilecoders.wicket.core.util.Components.assertTag(Components.java:65) ~[wicket-bootstrap-core-0.8.4.jar:?] 
    at de.agilecoders.wicket.core.markup.html.bootstrap.button.ButtonBehavior.onComponentTag(ButtonBehavior.java:134) ~[wicket-bootstrap-core-0.8.4.jar:?] 
    at org.apache.wicket.Component.renderComponentTag(Component.java:3970) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.Component.internalRenderComponent(Component.java:2540) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1493) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.Component.internalRender(Component.java:2379) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.Component.render(Component.java:2307) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1390) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1554) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1529) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.MarkupContainer.renderAssociatedMarkup(MarkupContainer.java:689) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.markup.html.panel.AssociatedMarkupSourcingStrategy.renderAssociatedMarkup(AssociatedMarkupSourcingStrategy.java:76) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.markup.html.panel.PanelMarkupSourcingStrategy.onComponentTagBody(PanelMarkupSourcingStrategy.java:112) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.Component.internalRenderComponent(Component.java:2549) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1493) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.Component.internalRender(Component.java:2379) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.Component.render(Component.java:2307) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1390) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1554) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1529) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1484) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy.onComponentTagBody(DefaultMarkupSourcingStrategy.java:71) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.Component.internalRenderComponent(Component.java:2549) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1493) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.Component.internalRender(Component.java:2379) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.Component.render(Component.java:2307) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1390) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1554) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1529) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1484) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy.onComponentTagBody(DefaultMarkupSourcingStrategy.java:71) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.Component.internalRenderComponent(Component.java:2549) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1493) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.Component.internalRender(Component.java:2379) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.Component.render(Component.java:2307) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1390) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1554) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1529) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1484) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.markup.html.form.Form.onComponentTagBody(Form.java:1683) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy.onComponentTagBody(DefaultMarkupSourcingStrategy.java:71) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.Component.internalRenderComponent(Component.java:2549) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1493) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.Component.internalRender(Component.java:2379) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.Component.render(Component.java:2307) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1390) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1554) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1529) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.MarkupContainer.renderAssociatedMarkup(MarkupContainer.java:689) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.markup.html.panel.AssociatedMarkupSourcingStrategy.renderAssociatedMarkup(AssociatedMarkupSourcingStrategy.java:76) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.markup.html.panel.PanelMarkupSourcingStrategy.onComponentTagBody(PanelMarkupSourcingStrategy.java:112) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.Component.internalRenderComponent(Component.java:2549) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1493) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.Component.internalRender(Component.java:2379) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.Component.render(Component.java:2307) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1390) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1554) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1529) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.MarkupContainer.renderAssociatedMarkup(MarkupContainer.java:689) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.markup.html.panel.AssociatedMarkupSourcingStrategy.renderAssociatedMarkup(AssociatedMarkupSourcingStrategy.java:76) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.markup.html.panel.PanelMarkupSourcingStrategy.onComponentTagBody(PanelMarkupSourcingStrategy.java:112) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.Component.internalRenderComponent(Component.java:2549) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1493) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.Component.internalRender(Component.java:2379) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.Component.render(Component.java:2307) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.ajax.XmlAjaxResponse.writeComponent(XmlAjaxResponse.java:127) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.ajax.AbstractAjaxResponse.writeComponents(AbstractAjaxResponse.java:213) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.ajax.AbstractAjaxResponse.writeTo(AbstractAjaxResponse.java:145) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.ajax.AjaxRequestHandler.respond(AjaxRequestHandler.java:363) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:861) ~[wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64) ~[wicket-request-6.9.0.jar:6.9.0] 
    at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:97) ~[wicket-request-6.9.0.jar:6.9.0] 
    at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:261) [wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:218) [wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:289) [wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:259) [wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:201) [wicket-core-6.9.0.jar:6.9.0] 
    at org.apache.wicket.protocol.http.WicketServlet.doGet(WicketServlet.java:137) [wicket-core-6.9.0.jar:6.9.0] 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) [servlet-api-2.5-20081211.jar:?] 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) [servlet-api-2.5-20081211.jar:?] 
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502) [jetty-6.1.15.jar:6.1.15] 
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1148) [jetty-6.1.15.jar:6.1.15] 
    at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:180) [spring-orm-3.2.8.RELEASE.jar:3.2.8.RELEASE] 
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-3.2.8.RELEASE.jar:3.2.8.RELEASE] 
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1139) [jetty-6.1.15.jar:6.1.15] 
    at org.apache.logging.log4j.core.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:66) [log4j-core-2.0-beta9.jar:2.0-beta9] 
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1139) [jetty-6.1.15.jar:6.1.15] 
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:378) [jetty-6.1.15.jar:6.1.15] 
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) [jetty-6.1.15.jar:6.1.15] 
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181) [jetty-6.1.15.jar:6.1.15] 
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765) [jetty-6.1.15.jar:6.1.15] 
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:417) [jetty-6.1.15.jar:6.1.15] 
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) [jetty-6.1.15.jar:6.1.15] 
    at org.mortbay.jetty.Server.handle(Server.java:324) [jetty-6.1.15.jar:6.1.15] 
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535) [jetty-6.1.15.jar:6.1.15] 
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:865) [jetty-6.1.15.jar:6.1.15] 
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539) [jetty-6.1.15.jar:6.1.15] 
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212) [jetty-6.1.15.jar:6.1.15] 
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) [jetty-6.1.15.jar:6.1.15] 
    at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228) [jetty-6.1.15.jar:6.1.15] 
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520) [jetty-util-6.1.15.jar:6.1.15] 
2014-10-27 12:22:10,627 WARN [[email protected] RequestCycleExtra] ******************************** 
2014-10-27 12:22:10,627 ERROR [[email protected] DefaultExceptionMapper] Unexpected error occurred 

但在標記我有這樣的:

<a wicket:id="printButton">Print View</a> 

而在java文件printButton中是BootstrapAjaxLink

如果我刪除禁用的形式,則是一切OK行...

回答

0

這是關於BootstrapAjaxLink,如果你look在它的源代碼,然後日子會把你看到的,它增加了ButtonBehavior,已經重寫onComponentTag方法(source)具有下列檢查:

Components.assertTag(component, tag, "a", "button", "input"); 

此代碼拋出錯誤,因爲禁用的鏈接標記爲span,正如您已經提到的那樣。

不知道,爲什麼會是這樣實現的,是的,你可以重寫disableLink方法,但更好的方法是使用BootstrapAjaxButton<input type="submit" value="ok"/>標記。

它僅將disabled="disabled"標記添加到禁用按鈕的標記,並且不會引發錯誤。

0

所以我發現,BootrstrapAjaxLink延伸AjaxLink具有以下方法:

@Override 
    protected void onComponentTag(ComponentTag tag) 
    { 
     super.onComponentTag(tag); 

     if (isLinkEnabled()) 
     { 
      // disable any href attr in markup 
      if (tag.getName().equalsIgnoreCase("a") || tag.getName().equalsIgnoreCase("link") || 
       tag.getName().equalsIgnoreCase("area")) 
      { 
       tag.put("href", "#"); 
      } 
     } 
     else 
     { 
      disableLink(tag); 
     } 

    } 

和disableLink竟把如下:

/** 
    * Alters the tag so that the link renders as disabled. 
    * 
    * This method is meant to be called from {@link #onComponentTag(ComponentTag)} method of the 
    * derived class. 
    * 
    * @param tag 
    */ 
    protected void disableLink(final ComponentTag tag) 
    { 
     // if the tag is an anchor proper 
     if (tag.getName().equalsIgnoreCase("a") || tag.getName().equalsIgnoreCase("link") || 
      tag.getName().equalsIgnoreCase("area")) 
     { 
      // Change anchor link to span tag 
      tag.setName("span"); 

      // Remove any href from the old link 
      tag.remove("href"); 

      tag.remove("onclick"); 
     } 
     // if the tag is a button or input 
     else if ("button".equalsIgnoreCase(tag.getName()) || 
      "input".equalsIgnoreCase(tag.getName())) 
     { 
      tag.put("disabled", "disabled"); 
     } 
    } 

這是問題......所以,如果我重寫這一點,它的工作原理......但爲什麼一個鏈接改爲跨越如果檢票口後抱怨它?

+2

從歷史上看,Wicket的鏈接在禁用時將標記更改爲跨度,這將在Wicket 7中更改(請參閱WICKET-4904)。請注意,它是投訴標籤名稱的wicket-bootstrap。 – svenmeier 2014-10-27 13:30:11