List of usage examples for org.apache.wicket.ajax AjaxRequestTarget prependJavaScript
void prependJavaScript(CharSequence javascript);
From source file:name.martingeisse.wicket.helpers.ExpandableRepeater.java
License:Open Source License
/** * Expands the number of visible batches by one. *///from w w w . j a va 2s.c o m public final void expandByOneBatch() { // Increment the batch count -- this will already cause a full render to consider the new batch. batchCount++; // In non-AJAX calls, that's it. In AJAX calls, we'll have to render an on-the-fly update. final AjaxRequestTarget target = AjaxRequestUtil.getAjaxRequestTarget(); if (target == null) { return; } // build items final int batchIndex = batchCount - 1; final List<E> batch = loadBatch(batchIndex); final int expansionSize = batch.size(); final StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("var newItemMarkupIds = ["); boolean first = true; for (int localIndex = 0; localIndex < expansionSize; localIndex++) { final IModel<E> listItemModel = new PropertyModel<E>(batch, Integer.toString(localIndex)); final Item<E> listItem = newItem(internalGetItemId(batchIndex, localIndex), listItemModel); add(listItem); populateItem(listItem); if (first) { first = false; } else { stringBuilder.append(','); } stringBuilder.append(JsUtil.toStringLiteralCharSequence(listItem.getMarkupId())); target.add(listItem); } // build append script stringBuilder.append("];\n"); stringBuilder.append("var $parent = $('#").append(initialItemMarkupId).append("').parent();"); stringBuilder.append("for (var i in newItemMarkupIds) {\n"); stringBuilder.append(" var item = document.createElement('").append(validElementType).append("'); "); stringBuilder.append(" item.id = newItemMarkupIds[i];"); stringBuilder.append(" $parent.append(item);"); stringBuilder.append("}\n"); target.prependJavaScript(stringBuilder); }
From source file:net.dontdrinkandroot.extensions.wicket.component.AppendingDataView.java
License:Apache License
public void appendNewItems(AjaxRequestTarget target, Component parent) { Iterator<IModel<T>> models = this.getItemModels(); Iterator<Item<T>> items = this.getItemReuseStrategy().getItems(this.newItemFactory(), models, this.getItems()); int index = (int) this.getFirstItemOffset(); while (items.hasNext()) { Item<T> item = items.next(); item.setOutputMarkupId(true);// ww w . j a v a2s. co m item.setIndex(index); this.add(item); ++index; target.prependJavaScript(String.format( "var item = document.createElement('%s'); item.id = '%s'; Wicket.$('%s').appendChild(item);", this.itemTagName, item.getMarkupId(), parent.getMarkupId())); target.add(item); } }
From source file:net.dontdrinkandroot.wicket.component.repeater.AppendingDataView.java
License:Apache License
public void appendNewItems(AjaxRequestTarget target, Component parent) { Iterator<IModel<T>> models = this.getItemModels(); Iterator<Item<T>> items = this.getItemReuseStrategy().getItems(this.newItemFactory(), models, this.getItems()); int index = (int) this.getFirstItemOffset(); while (items.hasNext()) { Item<T> item = items.next(); item.setOutputMarkupId(true);//from w ww . j a v a2 s. c o m item.setIndex(index); this.add(item); ++index; target.prependJavaScript(String.format( "var item = document.createElement('%s'); item.id = '%s'; Wicket.$('%s').appendChild(item);", this.itemTagName, item.getMarkupId(), parent.getMarkupId())); target.add(item); } }
From source file:net.ftlines.wicket.fullcalendar.callback.AbstractAjaxCallbackWithClientsideRevert.java
License:Apache License
@Override protected final void respond(AjaxRequestTarget target) { boolean result = onEvent(target); target.prependJavaScript(String.format("$.data(document, '%s', %s);", uuid, String.valueOf(result))); }
From source file:org.alienlabs.hatchetharry.view.page.HomePage.java
License:Open Source License
private void generateOpenConferenceLink(final String id) { this.add(new AjaxLink<Void>(id) { private static final long serialVersionUID = 1L; @Override/*from ww w. j a v a2 s .c om*/ public void onClick(final AjaxRequestTarget target) { target.prependJavaScript(BattlefieldService.HIDE_MENUS); target.appendJavaScript("jQuery('#conference').dialog('open');"); if (null != HomePage.this.session.getUsername()) { final User user = HomePage.this.persistenceService.getUser(HomePage.this.session.getUsername()); HomePage.LOGGER.info("###user: " + user); if (null != user) { target.appendJavaScript("jQuery('#txtDisplayName').val('" + user.getLogin() + "');"); target.appendJavaScript( "jQuery('#txtPrivateIdentity').val('" + user.getPrivateIdentity() + "');"); target.appendJavaScript("jQuery('#txtPublicIdentity').val('" + user.getIdentity() + "');"); target.appendJavaScript("jQuery('#txtPassword').val('" + user.getPassword() + "');"); target.appendJavaScript("jQuery('#txtRealm').val('" + user.getRealm() + "');"); } } } }); }
From source file:org.alienlabs.hatchetharry.view.page.HomePage.java
License:Open Source License
private ModalWindow generateAboutLink(final String id, final ModalWindow window) { window.setInitialWidth(450);/*from w w w . j a v a2 s . c o m*/ window.setInitialHeight(700); window.setTitle("About HatchetHarry"); window.setContent(new AboutModalWindow(window.getContentId(), window)); window.setCssClassName(ModalWindow.CSS_CLASS_GRAY); window.setMaskType(ModalWindow.MaskType.SEMI_TRANSPARENT); this.add(window); final AjaxLink<Void> aboutLink = new AjaxLink<Void>(id) { private static final long serialVersionUID = 8140325977385015896L; @Override public void onClick(final AjaxRequestTarget target) { target.prependJavaScript(BattlefieldService.HIDE_MENUS); target.appendJavaScript("Wicket.Window.unloadConfirmation = false;"); window.show(target); } }; aboutLink.setOutputMarkupId(true); window.setOutputMarkupId(true); this.add(aboutLink); return window; }
From source file:org.alienlabs.hatchetharry.view.page.HomePage.java
License:Open Source License
private ModalWindow generateMulliganLink(final String id, final ModalWindow window) { window.setInitialWidth(500);//from ww w .java 2 s .c o m window.setInitialHeight(150); window.setTitle("HatchetHarry - Mulligan"); window.setContent(new MulliganModalWindow(window, window.getContentId())); window.setCssClassName(ModalWindow.CSS_CLASS_GRAY); window.setMaskType(ModalWindow.MaskType.SEMI_TRANSPARENT); this.add(window); final AjaxLink<Void> mulliganLink = new AjaxLink<Void>(id) { private static final long serialVersionUID = 8140325977385015896L; @Override public void onClick(final AjaxRequestTarget target) { target.prependJavaScript(BattlefieldService.HIDE_MENUS); target.appendJavaScript("Wicket.Window.unloadConfirmation = false;"); window.show(target); } }; mulliganLink.setOutputMarkupId(true); window.setOutputMarkupId(true); this.add(mulliganLink); return window; }
From source file:org.alienlabs.hatchetharry.view.page.HomePage.java
License:Open Source License
private ModalWindow generateTeamInfoLink(final String id, final ModalWindow window) { window.setInitialWidth(475);/* w ww . ja va 2s. c o m*/ window.setInitialHeight(750); window.setTitle("HatchetHarry Team info"); window.setContent(new TeamInfoModalWindow(window.getContentId(), window)); window.setCssClassName(ModalWindow.CSS_CLASS_GRAY); window.setMaskType(ModalWindow.MaskType.SEMI_TRANSPARENT); this.add(window); final AjaxLink<Void> teamInfoLink = new AjaxLink<Void>(id) { private static final long serialVersionUID = 8140325977385015896L; @Override public void onClick(final AjaxRequestTarget target) { target.prependJavaScript(BattlefieldService.HIDE_MENUS); target.appendJavaScript("Wicket.Window.unloadConfirmation = false;"); window.show(target); } }; teamInfoLink.setOutputMarkupId(true); window.setOutputMarkupId(true); this.add(teamInfoLink); return window; }
From source file:org.alienlabs.hatchetharry.view.page.HomePage.java
License:Open Source License
private ModalWindow generateCreateGameModalWindow(final String id, final Player _player, final ModalWindow window) { window.setInitialWidth(475);/*from w w w . java 2 s . co m*/ window.setInitialHeight(550); window.setTitle("Create a match"); window.setContent(new CreateGameModalWindow(window, window.getContentId(), _player, this)); window.setCssClassName(ModalWindow.CSS_CLASS_GRAY); window.setMaskType(ModalWindow.MaskType.SEMI_TRANSPARENT); this.createGameLink = new AjaxLink<Void>(id) { private static final long serialVersionUID = 1L; @Override public void onClick(final AjaxRequestTarget _target) { _target.prependJavaScript(BattlefieldService.HIDE_MENUS); _target.appendJavaScript("Wicket.Window.unloadConfirmation = false;"); window.show(_target); } }; this.createGameLink.setOutputMarkupId(true).setMarkupId(id); this.createGameWindow.setOutputMarkupId(true); this.add(this.createGameLink); return window; }
From source file:org.alienlabs.hatchetharry.view.page.HomePage.java
License:Open Source License
private ModalWindow generateJoinGameModalWindow(final String id, final Player _player, final ModalWindow window) { window.setInitialWidth(475);/* w w w . j a v a2 s . c o m*/ window.setInitialHeight(430); window.setTitle("Join a match"); window.setContent( new JoinGameModalWindow(window, window.getContentId(), _player, this.dataBoxParent, this)); window.setCssClassName(ModalWindow.CSS_CLASS_GRAY); window.setMaskType(ModalWindow.MaskType.SEMI_TRANSPARENT); this.joinGameLink = new AjaxLink<Void>(id) { private static final long serialVersionUID = 1L; @Override public void onClick(final AjaxRequestTarget _target) { _target.prependJavaScript(BattlefieldService.HIDE_MENUS); _target.appendJavaScript("Wicket.Window.unloadConfirmation = false;"); window.show(_target); } }; this.joinGameLink.setOutputMarkupId(true).setMarkupId(id); window.setOutputMarkupId(true); this.add(this.joinGameLink); return window; }