Example usage for org.apache.wicket.ajax.markup.html AjaxLink setOutputMarkupId

List of usage examples for org.apache.wicket.ajax.markup.html AjaxLink setOutputMarkupId

Introduction

In this page you can find the example usage for org.apache.wicket.ajax.markup.html AjaxLink setOutputMarkupId.

Prototype

public final Component setOutputMarkupId(final boolean output) 

Source Link

Document

Sets whether or not component will output id attribute into the markup.

Usage

From source file:gr.abiss.calipso.wicket.SearchOnAnotherSpacePanel.java

License:Open Source License

private void addComponents() {
    final List<Space> userSpaces = new ArrayList<Space>(getPrincipal().getSpaces());

    if (getCurrentSpace() != null) {
        //Use, for all space search
        Space emptySpace = new Space();
        emptySpace.setId(0);/*w ww .  j  ava  2  s. c o m*/
        emptySpace.setName(localize("item_search_form.allSpaces"));
        emptySpace.setPrefixCode("");

        userSpaces.add(0, emptySpace);
        userSpaces.remove(getCurrentSpace());
    }

    // -- Spaces Drop Down List ------------------------------------------- 
    final DropDownChoice allSpaces = new DropDownChoice("allSpaces", new Model(), userSpaces,
            new IChoiceRenderer() {
                public String getIdValue(Object object, int index) {
                    return String.valueOf(((Space) object).getId());
                }

                public Object getDisplayValue(Object object) {
                    return localize(((Space) object).getNameTranslationResourceKey());
                }
            });
    allSpaces.setNullValid(false);
    allSpaces.setOutputMarkupId(true);

    allSpaces.add(new AjaxFormComponentUpdatingBehavior("onchange") {
        protected void onUpdate(AjaxRequestTarget target) {
            //Do nothing. Needed for get its value via ajax.
        }//onUpdate
    });

    add(allSpaces);

    // -- Search Button -------------------------------------------
    final AjaxLink go = new AjaxLink("go") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            target.addComponent(allSpaces);
            if (allSpaces.getValue() != null && !allSpaces.getValue().equals("")
                    && !allSpaces.getValue().equals("-1")) {
                if (allSpaces.getValue().equals("0")) {//All Spaces
                    ((CalipsoSession) getSession()).setCurrentSpace(null);
                    setResponsePage(ItemSearchFormPage.class);
                } //if
                else {
                    Space selectedSpace = getCalipso().loadSpace(Long.parseLong(allSpaces.getValue()));
                    for (Space space : userSpaces) {
                        if (space.equals(selectedSpace)) {
                            setCurrentSpace(space);
                            setResponsePage(ItemSearchFormPage.class);
                        } //if
                    } //for
                } //else
            }
        }
    };
    go.setOutputMarkupId(true);
    add(go);
}

From source file:org.alienlabs.hatchetharry.view.page.HomePage.java

License:Open Source License

private void buildCombatLink() {
    final WebMarkupContainer combatPlaceholder = new WebMarkupContainer("combatPlaceholder");
    combatPlaceholder.setMarkupId("combatPlaceholder");
    combatPlaceholder.setOutputMarkupId(true);

    final AjaxLink<Void> combatLink = new IndicatingAjaxLink<Void>("combatLink") {
        private static final long serialVersionUID = 1L;

        @Override/*from  w  ww  .ja va  2s.  co m*/
        public void onClick(final AjaxRequestTarget target) {
            HomePage.LOGGER.info("clicked on declare combat");
            HomePage.this.session
                    .setCombatInProgress(!HomePage.this.session.isCombatInProgress().booleanValue());
            final Long _gameId = HomePage.this.session.getGameId();
            final List<BigInteger> allPlayersInGame = HomePage.this.persistenceService
                    .giveAllPlayersFromGame(_gameId);

            final NotifierCometChannel ncc = new NotifierCometChannel(NotifierAction.COMBAT_IN_PROGRESS_ACTION,
                    null, null, HomePage.this.session.getPlayer().getName(), "", "",
                    HomePage.this.session.isCombatInProgress(), "");
            final ConsoleLogStrategy logger = AbstractConsoleLogStrategy.chooseStrategy(ConsoleLogType.COMBAT,
                    null, null, HomePage.this.session.isCombatInProgress(), null,
                    HomePage.this.session.getPlayer().getName(), null, null, null, Boolean.FALSE, _gameId);

            EventBusPostService.post(allPlayersInGame, ncc, new ConsoleLogCometChannel(logger));
        }
    };
    combatLink.setMarkupId("combatLink");
    combatLink.setOutputMarkupId(true);

    combatPlaceholder.add(combatLink);

    this.add(combatPlaceholder);
}

From source file:org.alienlabs.hatchetharry.view.page.HomePage.java

License:Open Source License

private void generateDrawCardLink() {
    final AjaxLink<String> drawCardLink = new IndicatingAjaxLink<String>("drawCardLink") {
        private static final long serialVersionUID = 1L;

        @Override/*ww  w. j  a  va 2  s  .c  o  m*/
        public void onClick(final AjaxRequestTarget target) {
            Long _gameId = HomePage.this.session.getPlayer().getGame().getId();
            Long deckId = HomePage.this.session.getPlayer().getDeck().getDeckId();

            final List<MagicCard> cards = HomePage.this.persistenceService.getAllCardsInLibraryForDeckAndPlayer(
                    _gameId, HomePage.this.session.getPlayer().getId(), deckId);

            if ((cards != null) && (!cards.isEmpty())) {
                final MagicCard card = cards.get(0);

                final Deck _deck = HomePage.this.persistenceService.getDeck(deckId.longValue());
                _deck.getCards().remove(card);
                HomePage.this.persistenceService.saveOrUpdateDeck(_deck);

                card.setZone(CardZone.HAND);

                List<MagicCard> allCardsInHand = HomePage.this.persistenceService
                        .getAllCardsInHandForAGameAndADeck(_gameId, deckId);
                if (!allCardsInHand.isEmpty()) {
                    card.setZoneOrder(allCardsInHand.get(allCardsInHand.size() - 1).getZoneOrder() + 1L);
                }

                HomePage.this.persistenceService.updateCard(card);

                final ArrayList<MagicCard> list = HomePage.this.session.getFirstCardsInHand();
                list.add(card);
                HomePage.this.session.setFirstCardsInHand(list);

                BattlefieldService.updateHand(target);

                final Player me = HomePage.this.session.getPlayer();
                final Long __gameId = HomePage.this.persistenceService
                        .getPlayer(HomePage.this.session.getPlayer().getId()).getGame().getId();

                final Deck d = me.getDeck();
                final List<MagicCard> _hand = d.reorderMagicCards(HomePage.this.persistenceService
                        .getAllCardsInHandForAGameAndADeck(__gameId, d.getDeckId()));
                HomePage.this.persistenceService.saveOrUpdateAllMagicCards(_hand);
                final List<MagicCard> library = d.reorderMagicCards(HomePage.this.persistenceService
                        .getAllCardsInLibraryForDeckAndPlayer(__gameId, me.getId(), d.getDeckId()));
                HomePage.this.persistenceService.saveOrUpdateAllMagicCards(library);

                final ConsoleLogStrategy logger = AbstractConsoleLogStrategy.chooseStrategy(
                        ConsoleLogType.DRAW_CARD, null, null, null, null,
                        HomePage.this.session.getPlayer().getName(), null, null, null, null, __gameId);
                final NotifierCometChannel ncc = new NotifierCometChannel(NotifierAction.DRAW_CARD_ACTION, null,
                        me.getId(), me.getName(), me.getSide().getSideName(), null, null, "");

                final List<BigInteger> allPlayersInGame = HomePage.this.persistenceService
                        .giveAllPlayersFromGame(__gameId);
                EventBusPostService.post(allPlayersInGame, ncc, new ConsoleLogCometChannel(logger));
            } else {
                throw new RuntimeException(
                        "You've lost since you have no more card to draw. All your base are belong to us!");
            }
        }

        @Override
        protected void onComponentTag(final ComponentTag tag) {
            super.onComponentTag(tag);

            if ("a".equalsIgnoreCase(tag.getName()) || "link".equalsIgnoreCase(tag.getName())
                    || "area".equalsIgnoreCase(tag.getName())) {
                tag.put("href", "");
            } else {
                this.disableLink(tag);
            }

        }
    };

    drawCardLink.setOutputMarkupId(true).setMarkupId("drawCardLink");
    this.add(drawCardLink);
}

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);/* w  ww  . j av 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);//  w w w .  j a v  a  2s.  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 w  w.j a va2  s . 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 void generateImportDeckLink(final String id) {
    final AjaxLink<Void> importDeckLink = new AjaxLink<Void>(id) {
        private static final long serialVersionUID = 1L;

        @Override/*from  w ww  . ja va  2 s  .  co m*/
        public void onClick(final AjaxRequestTarget target) {
            target.prependJavaScript(BattlefieldService.HIDE_MENUS);
            target.appendJavaScript("jQuery('#importDeck').dialog('open');");
        }
    };

    importDeckLink.setOutputMarkupId(true);
    this.importDeckDialog.setOutputMarkupId(true);
    this.add(importDeckLink);
}

From source file:org.alienlabs.hatchetharry.view.page.HomePage.java

License:Open Source License

private void generateRevealTopLibraryCardLink(final String id, final String idModalWindow) {
    final ModalWindow window = new ModalWindow(idModalWindow);
    window.setWindowClosedCallback(new WindowClosedCallback() {
        private static final long serialVersionUID = 1L;

        @Override/*from   w w  w .  j av  a2  s  . co m*/
        public void onClose(final AjaxRequestTarget target) {
            if (HomePage.this.session.getTopCardIndex() > 0L) {
                HomePage.this.session
                        .setTopCardIndex(Long.valueOf(HomePage.this.session.getTopCardIndex() - 1L));
            }

        }
    });
    window.setInitialWidth(500);
    window.setInitialHeight(510);

    final List<MagicCard> allCardsInLibrary = this.persistenceService.getAllCardsInLibraryForDeckAndPlayer(
            this.session.getGameId(), this.session.getPlayer().getId(),
            this.session.getPlayer().getDeck().getDeckId());
    final MagicCard firstCard;

    if (allCardsInLibrary.isEmpty()) {
        firstCard = null;
    } else {
        firstCard = allCardsInLibrary.get(this.session.getTopCardIndex().intValue());
    }

    window.setContent(new RevealTopLibraryCardModalWindow(window.getContentId(), window, firstCard));

    window.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    window.setMaskType(ModalWindow.MaskType.SEMI_TRANSPARENT);
    window.setOutputMarkupId(true);

    this.revealTopLibraryCardWindow = window;
    this.add(this.revealTopLibraryCardWindow);

    final AjaxLink<Void> revealTopLibraryCardLink = new AjaxLink<Void>(id) {
        private static final long serialVersionUID = 1L;

        @SuppressWarnings("boxing")
        @SuppressFBWarnings({ "PATH_TRAVERSAL_IN", "PATH_TRAVERSAL_IN" })
        @Override
        public void onClick(final AjaxRequestTarget target) {
            final List<MagicCard> _allCardsInLibrary = HomePage.this.persistenceService
                    .getAllCardsInLibraryForDeckAndPlayer(HomePage.this.session.getGameId(),
                            HomePage.this.session.getPlayer().getId(),
                            HomePage.this.session.getPlayer().getDeck().getDeckId());
            if (_allCardsInLibrary.isEmpty()) {
                return;
            }

            final MagicCard _firstCard = _allCardsInLibrary
                    .get(HomePage.this.session.getTopCardIndex().intValue());
            final String topCardName = _firstCard.getBigImageFilename();

            final String cardPath = ResourceBundle.getBundle(HatchetHarryApplication.class.getCanonicalName())
                    .getString("SharedResourceFolder");
            final String cardPathAndName = cardPath.replace("/cards", "") + topCardName;
            final File from = new File(cardPathAndName);
            final File to = new File(cardPath + "topLibraryCard.jpg");

            try {
                Files.copy(from, to);
            } catch (final IOException e) {
                HomePage.LOGGER.error(
                        "could not copy from: " + cardPathAndName + " to: " + cardPath + "topLibraryCard.jpg",
                        e);
            }

            final Long _gameId = HomePage.this.persistenceService
                    .getPlayer(HomePage.this.session.getPlayer().getId()).getGame().getId();
            final RevealTopLibraryCardCometChannel chan = new RevealTopLibraryCardCometChannel(
                    HomePage.this.session.getPlayer().getName(), _firstCard,
                    HomePage.this.session.getTopCardIndex());
            final ConsoleLogStrategy logger = AbstractConsoleLogStrategy.chooseStrategy(
                    ConsoleLogType.REVEAL_TOP_CARD_OF_LIBRARY, null, null, null, _firstCard.getTitle(),
                    HomePage.this.session.getPlayer().getName(), null,
                    HomePage.this.session.getTopCardIndex() + 1L, null, Boolean.FALSE, _gameId);
            final List<BigInteger> allPlayersInGame = HomePage.this.persistenceService
                    .giveAllPlayersFromGame(_gameId);

            EventBusPostService.post(allPlayersInGame, chan, new ConsoleLogCometChannel(logger));
        }
    };

    revealTopLibraryCardLink.setOutputMarkupId(true).setMarkupId(id);
    this.add(revealTopLibraryCardLink);
}

From source file:org.alienlabs.hatchetharry.view.page.HomePage.java

License:Open Source License

private void generateCreateTokenLink(final String id, final ModalWindow window) {
    window.setInitialWidth(500);//  www.j  a  v a 2s .co m
    window.setInitialHeight(510);

    final CreateTokenModalWindow createTokenModalWindow = new CreateTokenModalWindow(window.getContentId(),
            window);
    window.setContent(createTokenModalWindow);
    window.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    window.setMaskType(ModalWindow.MaskType.SEMI_TRANSPARENT);
    window.setTitle("Create a token");
    window.setOutputMarkupId(true);
    this.setCreateTokenModalWindow(window);
    this.add(window);

    final AjaxLink<Void> createTokenLink = 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;");

            HomePage.this.createTokenWindow.show(target);
        }
    };

    createTokenLink.setOutputMarkupId(true).setMarkupId(id);
    this.add(createTokenLink);
}

From source file:org.alienlabs.hatchetharry.view.page.HomePage.java

License:Open Source License

private void generateCountCardsLink(final String id, final ModalWindow window) {
    window.setInitialWidth(740);/* w  w  w.  j a va2s  .c o  m*/
    window.setInitialHeight(550);

    window.setContent(new CountCardsModalWindow(window.getContentId(), this.session.getGameId()));
    window.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    window.setMaskType(ModalWindow.MaskType.SEMI_TRANSPARENT);
    window.setOutputMarkupId(true);
    this.add(window);

    final AjaxLink<Void> countCardsLink = new AjaxLink<Void>(id) {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            target.prependJavaScript(BattlefieldService.HIDE_MENUS);

            final Long _gameId = HomePage.this.session.getGameId();
            final CountCardsCometChannel cccc = new CountCardsCometChannel(_gameId,
                    HomePage.this.session.getPlayer().getName());

            final List<BigInteger> allPlayersInGame = HomePage.this.persistenceService
                    .giveAllPlayersFromGame(_gameId);
            EventBusPostService.post(allPlayersInGame, cccc);
        }
    };

    countCardsLink.setOutputMarkupId(true);
    this.add(countCardsLink);
}