0

I migrated from Wicket 7 to Wicket 8. Now OnLoadBehavior does not work anymore. I need to show some hidden fields in the view using target.add() inside onEvent e.g.

if (showDateElement) {
   dateElement.setVisible(true);
   target.add(dateElement);
}

Issue is that method onEvent is not called anymore as it was in previous version. No other code changes. This occurs in Firefox. Chrome seems to work most of the time, but not always. Is there some other way to do this same reliably in Wicket 8?

I hope someone can help.

add(new OnLoadBehavior());

private final class OnLoadBehavior extends AjaxEventBehavior {

    private OnLoadBehavior() {
        super("load");
        LOG.debug("OnLoadBehavior");
    }

    @Override
    protected void onEvent(final AjaxRequestTarget target) {
        LOG.debug("OnLoadBehavior onEvent");
    }
}
JRM
  • 61
  • 7
  • Check for JavaScript errors in the Firefox DevTools > Console. – martin-g May 11 '21 at 06:33
  • There are no errors in console. It prints constructors "OnLoadBevior" to console, but "OnLoadBehavior onEvent" is never printed on page load. – JRM May 11 '21 at 06:42
  • You talk about server logs. I talk about client side logs. – martin-g May 11 '21 at 07:06
  • Oh yes. My mistake. That happens in server log. In client side log there is no errors in Firefox console which is weird... – JRM May 11 '21 at 07:22
  • 1
    Now please check in Firefox DevTools > Network tab whether it makes an Ajax call at all. On what Wicket Component do you add this behavior ? What HTML element corresponds to this component ? – martin-g May 11 '21 at 07:52
  • Behaviour is added on a page that extends org.apache.wicket.markup.html.WebPage. I have few components that need update in the onEvent method, but that onEvent is not reliably called. Page loads otherwise ok when entered, but those few components wont update visible as the method is not called (chrome calls usually, firefox close to never). – JRM May 11 '21 at 13:16

0 Answers0