List of usage examples for org.apache.wicket.ajax AjaxRequestTarget add
void add(Component... components);
From source file:com.comcast.cdn.traffic_control.traffic_monitor.wicket.behaviors.MultiUpdatingTimerBehavior.java
License:Apache License
/** * Re-enables the timer if already stopped * * @param target/*from w w w . j a v a 2s .co m*/ */ public final void restart(final AjaxRequestTarget target) { if (isStopped()) { stopped = false; headRendered = false; target.add(getComponent()); } }
From source file:com.comcast.cdn.traffic_control.traffic_monitor.wicket.components.AddPanel.java
License:Apache License
public AddPanel(final String id) { super(id);/*w w w .j av a 2 s . c o m*/ this.setOutputMarkupId(true); editform = new Form<Object>("editform"); addlink = new AjaxFallbackLink<Object>("add") { private static final long serialVersionUID = 1L; @Override public void onClick(final AjaxRequestTarget target) { AddPanel.this.showForm(true); if (target != null) { target.add(AddPanel.this); } } }; add(addlink); field = new TextField<String>("field", new Model<String>("")); editform.add(field); editform.add(new AjaxLink<Object>("cancel") { private static final long serialVersionUID = 1L; @Override public void onClick(final AjaxRequestTarget target) { AddPanel.this.showForm(false); if (target != null) { target.add(AddPanel.this); } } }); editform.add(new AjaxButton("submit", editform) { private static final long serialVersionUID = 1L; @Override public void onSubmit(final AjaxRequestTarget target, final Form<?> form) { addResponse(field.getModelObject().toString(), target); AddPanel.this.showForm(false); if (target != null) { target.add(AddPanel.this); } } }); this.add(editform); showForm(false); }
From source file:com.comcast.cdn.traffic_control.traffic_monitor.wicket.components.CacheListPanel.java
License:Apache License
public CacheListPanel(final String id, final Behavior updater, final Component[] updateList) { super(id);// www .j a v a 2 s . c o m final ModalWindow modal1; add(modal1 = new ModalWindow("modal1")); modal1.setInitialWidth(1000); // modal1.setCookieName("modal-1"); modal1.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = 1L; public Page createPage() { return new CacheDetailsPage(hostname); } }); this.updateList = updateList; final WebMarkupContainer container = new WebMarkupContainer("listpanel"); container.setOutputMarkupId(true); add(container); servers = createServerListView(updater, modal1); servers.setOutputMarkupId(true); container.setOutputMarkupId(true); container.add(servers); add(new AbstractAjaxTimerBehavior(Duration.seconds(1)) { private static final long serialVersionUID = 1L; int serverCount = 0; @Override protected final void onTimer(final AjaxRequestTarget target) { // target.add(getComponent()); final int size = CacheState.getCacheStates().size(); if (serverCount != size) { serverCount = size; servers.setList(getServerList()); target.add(container); if (updateList != null) { for (Component c : updateList) { target.add(c); } } // target.add(graph); } } }); }
From source file:com.comcast.cdn.traffic_control.traffic_monitor.wicket.components.DsListPanel.java
License:Apache License
public DsListPanel(final String id, final Behavior updater, final Component[] updateList) { super(id);// w w w. j a va2 s . co m final ModalWindow modal1; add(modal1 = new ModalWindow("modal2")); modal1.setInitialWidth(1000); // modal1.setCookieName("modal-1"); modal1.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = 1L; public Page createPage() { return new DsDetailsPage(dsId); } }); this.updateList = updateList; final WebMarkupContainer container = new WebMarkupContainer("listpanel"); container.setOutputMarkupId(true); add(container); servers = createDsListView(updater, modal1); servers.setOutputMarkupId(true); container.setOutputMarkupId(true); container.add(servers); add(new AbstractAjaxTimerBehavior(Duration.seconds(1)) { private static final long serialVersionUID = 1L; int serverCount = 0; @Override protected final void onTimer(final AjaxRequestTarget target) { final int size = DsState.getDsStates().size(); if (serverCount != size) { serverCount = size; servers.setList(getDsList()); target.add(container); if (updateList != null) { for (Component c : updateList) { target.add(c); } } } } }); }
From source file:com.comcast.cdn.traffic_control.traffic_monitor.wicket.components.EditConfigPanel.java
License:Apache License
private final void setForm(final Form<MonitorConfig> editform, final Map<String, String> baseconfig) { final MonitorConfig config = ConfigHandler.getConfig(); if (config == null || !config.allowConfigEdit()) { return;//w w w . j a v a2s . co m } final List<String> keys = sort(baseconfig.keySet()); keys.remove(TM_HOSTNAME_KEY); keys.remove(CDN_NAME_KEY); final List<String> TM_HOSTS = Arrays.asList(new String[] { "tm.company.net" }); final ArrayList<String> cdnList = new ArrayList<String>(); final String hostName = baseconfig.get(TM_HOSTNAME_KEY); setCdnList(cdnList, hostName); final AjaxEditableChoiceLabel<String> tmHost = new AjaxEditableChoiceLabel<String>("tmHost", new BaseConfigModel(TM_HOSTNAME_KEY, baseconfig), TM_HOSTS) { private static final long serialVersionUID = 1L; @Override protected void onSubmit(final AjaxRequestTarget target) { super.onSubmit(target); final String hostName = baseconfig.get(TM_HOSTNAME_KEY); setCdnList(cdnList, hostName); target.add(cdnName); } }; // listSites editform.add(tmHost); cdnName = new AjaxEditableChoiceLabel<String>(CDN_NAME_KEY, new BaseConfigModel(CDN_NAME_KEY, baseconfig), new WildcardListModel<String>(cdnList)); // listSites editform.add(cdnName); final ListView<String> propView = new ListView<String>("propList", keys) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<String> item) { final String key = item.getModelObject(); final Label label = new Label("key", key); item.add(label); // editform.add(new TextField("value", new Model<String>(baseconfig.get(key)))) ; item.add(new AjaxEditableLabel<String>("value", new BaseConfigModel(key, baseconfig))); item.add(label); } }; editform.add(propView); editform.add(new AjaxLink<Object>("cancel") { private static final long serialVersionUID = 1L; @Override public void onClick(final AjaxRequestTarget target) { final Map<String, String> oldProps = ConfigHandler.getConfig().getBaseProps(); baseconfig.putAll(oldProps); final String hostName = baseconfig.get(TM_HOSTNAME_KEY); setCdnList(cdnList, hostName); if (target != null) { target.add(EditConfigPanel.this); } } }); editform.add(new AjaxButton("submit", editform) { private static final long serialVersionUID = 1L; @Override public void onSubmit(final AjaxRequestTarget target, final Form<?> form) { try { ConfigHandler.saveBaseConfig(baseconfig); TmWatcher.getInstance().refresh(); } catch (JSONException e) { LOGGER.warn(e, e); } catch (IOException e) { LOGGER.warn(e, e); } // EditConfigPanel.this.showForm(false); if (target != null) { target.add(EditConfigPanel.this); } } }); }
From source file:com.conwax.ajax.examples.AjaxFallbackLinkPage.java
License:Apache License
public AjaxFallbackLinkPage() { super();/*from www. jav a2 s . c o m*/ final Label label = new Label("label", new PropertyModel<Integer>(this, "counter")); label.setOutputMarkupId(true); add(label); add(new AjaxFallbackLink<Void>("link") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { counter++; if (null != target) { target.add(label); } } }); }
From source file:com.conwax.ajax.examples.AjaxLinkPage.java
License:Apache License
public AjaxLinkPage() { super();//from www . jav a2s .c om final Label label = new Label("label", new PropertyModel<Integer>(this, "counter")); label.setOutputMarkupId(true); add(label); add(new AjaxLink<Void>("link") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { counter++; target.add(label); } }); }
From source file:com.cubeia.games.poker.admin.wicket.pages.tournaments.scheduled.CreateTournament.java
License:Open Source License
private void addRebuyPanel(Form<ScheduledTournamentForm> tournamentForm) { CheckBox enableRebuys = new CheckBox("rebuysEnabled"); enableRebuys.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override//from w w w . j a v a 2 s . c o m protected void onUpdate(AjaxRequestTarget target) { log.debug("Setting enabled " + !rebuyConfigurationPanel.isEnabled()); rebuyConfigurationPanel.setRebuysEnabled(!rebuyConfigurationPanel.isEnabled()); target.add(rebuyConfigurationPanel); } }); tournamentForm.add(enableRebuys); rebuyConfigurationPanel = new RebuyConfigurationPanel("rebuyConfiguration", configuration.getObject().getRebuyConfiguration(), false); rebuyConfigurationPanel.setOutputMarkupId(true); tournamentForm.add(rebuyConfigurationPanel); }
From source file:com.cubeia.games.poker.admin.wicket.pages.tournaments.scheduled.EditTournament.java
License:Open Source License
private void addPreviewSchedule(Form<ScheduledTournamentConfiguration> tournamentForm) { WebMarkupContainer pc = new WebMarkupContainer("previewContainer"); pc.setOutputMarkupId(true);/*from ww w. j av a 2 s .co m*/ final SchedulePreviewPanel previewContent = new SchedulePreviewPanel("previewContent"); previewContent.setOutputMarkupId(true); TournamentSchedule schedule = tournament.getSchedule(); if (schedule != null) { previewContent.setSchedule(schedule); } pcAjaxBehaviour = new AbstractDefaultAjaxBehavior() { @Override protected void respond(AjaxRequestTarget target) { IRequestParameters params = getRequestCycle().getRequest().getRequestParameters(); SimpleDateFormat sdf = new SimpleDateFormat(new DateTextField("dummy").getTextFormat()); String cron = params.getParameterValue("cron").toOptionalString(); int minInAnnounced = params.getParameterValue("announceMinutes").toInt(0); int minInRegistering = params.getParameterValue("registeringMinutes").toInt(0); int minAfterClose = params.getParameterValue("visibleMinutes").toInt(0); Date start = new Date(0); Date end = new Date(0); try { start = sdf.parse(params.getParameterValue("start").toString()); end = sdf.parse(params.getParameterValue("end").toString()); } catch (ParseException e) { log.warn("error parsing start/end date"); } updatePreviewValues(previewContent, cron, start, end, minInAnnounced, minInRegistering, minAfterClose); target.add(previewContent); } }; pc.add(pcAjaxBehaviour); pc.add(previewContent); tournamentForm.add(pc); }
From source file:com.cubeia.games.poker.admin.wicket.pages.tournaments.scheduled.EditTournament.java
License:Open Source License
private void addRebuyPanel(Form<ScheduledTournamentConfiguration> tournamentForm) { if (tournament.getConfiguration().getRebuyConfiguration() == null) { tournament.getConfiguration().setRebuyConfiguration(new RebuyConfiguration()); }/*from www .j a va 2s . c o m*/ boolean enabled = tournament.getConfiguration().getRebuyConfiguration().getNumberOfRebuysAllowed() != 0; rebuysEnabled.setObject(enabled); CheckBox enableRebuys = new CheckBox("rebuysEnabled", rebuysEnabled); enableRebuys.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { log.debug("rr " + tournament.getConfiguration().getRebuyConfiguration().getNumberOfRebuysAllowed()); rebuyConfigurationPanel.setRebuysEnabled(!rebuyConfigurationPanel.isEnabled()); target.add(rebuyConfigurationPanel); } }); tournamentForm.add(enableRebuys); rebuyConfigurationPanel = new RebuyConfigurationPanel("rebuyConfiguration", tournament.getConfiguration().getRebuyConfiguration(), enabled); rebuyConfigurationPanel.setOutputMarkupId(true); tournamentForm.add(rebuyConfigurationPanel); }