wicketwicket-1.6

Wicket 1.6 Enabling a Link Component on a disabled panel


We are currently struggling with getting a single AjaxLink or Link component to enable on a panel that is disabled. When using either the AjaxLink or the Link component the onClick() event never appears to get called. The AjaxLink behaves as thought its never getting click on, and the Link component allows the click but the following exception is thrown:

Component rejected interface invocationComponent: [Link [Component id = groupReviewLink]] Listener: [RequestListenerInterface name=ILinkListener, method=public abstract void org.apache.wicket.markup.html.link.ILinkListener.onLinkClicked()]

We have found a work around via using ExternalLink and it appears to work but we would prefer not to use that as a solution if possible.

I searched around and found the following solution/example -

Wicket : enabling a panel component while entire panel is disabled explicitly

Unfortunately it doesn't appear to resolve my situation.

We have attempted to override the isEnabled() and isLinkEnabled() as suggested by the other thread but have had no success. Any idea of how to make this work would be great.

        AjaxLink groupReviewLink = new AjaxLink("groupReviewLink") {
            private static final long serialVersionUID = 1L;
            
            @Override
            public void onClick(AjaxRequestTarget arg0) {
                throw new RedirectToUrlException("reviews?reviewCount=12");
            }
                         
            @Override
            public boolean isEnabled() {
                // TODO Auto-generated method stub
                return true;
            }
            
            @Override
            protected boolean isLinkEnabled() {
                // TODO Auto-generated method stub
                return true;
            }
        
        };

Solution

  • You need to override #isEnabledInHierarchy() method if some of the parents is disabled, like in your case.