private void addPinger() { final Duration pingerInterval = getPluginConfig().getAsDuration(CONFIG_PINGER_INTERVAL); add(new Pinger("pinger", pingerInterval)); }
/** * Starts a default ping wicket components which uses the indicated duration between ping intervals. * After the elapse of each interval a roundtrip to the server is made using an Ajax call. * When the duration is negative, this wicket component behaves like a plain Label widget. * @param id the wicket id to use * @param interval the time to wait between ping interfals */ public Pinger(String id, Duration interval) { super(id); if (interval != null) { if (interval.greaterThan(0L)) { add(new PingBehavior(interval)); } } else { add(new PingBehavior(Duration.seconds(DEFAULT_INTERVAL_SECONDS))); } }
public RootPlugin(IPluginContext context, IPluginConfig config) { super(context, config); add(new GlobalJsResourceBehavior()); if (config.containsKey("pinger.interval")) { add(new Pinger("pinger", config.getAsDuration("pinger.interval"))); } else { add(new Pinger("pinger")); } if (config.getString(RenderService.MODEL_ID) != null) { String modelId = config.getString(RenderService.MODEL_ID); ModelReference modelService = new ModelReference(modelId, new JcrNodeModel("/")); modelService.init(context); // unregister: don't repaint root plugin when model changes. context.unregisterService(this, modelId); } PageLayoutSettings plSettings = new PageLayoutSettings(); try { PluginConfigMapper.populate(plSettings, config.getPluginConfig("yui.config")); } catch (MappingException e) { throw new RuntimeException(e); } add(new PageLayoutBehavior(plSettings)); }