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

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

Introduction

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

Prototype

public AjaxLink(final String id) 

Source Link

Document

Construct.

Usage

From source file:nl.knaw.dans.dccd.web.user.SelectUserFromTablePanel.java

License:Apache License

private void init() {
    List<DccdUser> selectableUsers = null;
    try {// w w w .  ja  v  a2 s . co  m
        // Note: when we do it pageable, it seems better to get only the id's 
        // and then construct the users we want to show on a page

        // only active ... selectable (permission assignable) users
        selectableUsers = DccdUserService.getService().getActiveNormalUsers();

        // remove current user, might take some time if the list is long
        DccdUser user = (DccdUser) ((DccdSession) getSession()).getUser();
        String currentUserId = user.getId();
        Iterator<DccdUser> iterator = selectableUsers.iterator();
        while (iterator.hasNext()) {
            DccdUser selectableUser = (DccdUser) iterator.next();
            if (selectableUser.getId().compareTo(currentUserId) == 0) {
                iterator.remove();
                break; // done, because only once in the list
            }
        }
    } catch (UserServiceException e) {
        logger.error("Exception while retrieving users: ", e);
        error("Internal error");
        throw new RestartResponseException(ErrorPage.class);
    }

    // show table with all active DCCD users
    // when we have a lot of users, this should become pagable! 
    ListView listview = new ListView("listview", selectableUsers) {
        private static final long serialVersionUID = -2830791437271425906L;

        protected void populateItem(ListItem item) {
            final DccdUser user = (DccdUser) item.getModelObject();
            AjaxLink link = new AjaxLink("link") {
                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    selectedUserId = user.getId();
                    logger.debug("selected user id: " + selectedUserId);

                    // update
                    SelectUserFromTablePanel.this.setDefaultModelObject(user);
                    onSelectionChanged(target);
                }
            };
            item.add(link);
            item.add(new Label("surname", user.getSurname()));
            item.add(new Label("displayname", user.getDisplayName()));
            item.add(new Label("organisation", user.getOrganization()));
        }
    };
    add(listview);
}

From source file:nl.mpi.lamus.web.pages.LamusPage.java

License:Open Source License

/**
 * edit title of the page, logo and userName
 *///from  ww  w .j ava  2s.  c  o m
@SuppressWarnings("LeakingThisInConstructor")
public LamusPage() {
    super();

    String appName = getLocalizer().getString("header_app_name", this);

    feedbackPanel = new FeedbackPanel("feedbackPanel");
    feedbackPanel.setOutputMarkupId(true);
    feedbackPanel.setOutputMarkupPlaceholderTag(true);
    feedbackPanel.setEscapeModelStrings(false);

    add(feedbackPanel);

    add(new Image("header_tla_logo", new SharedResourceReference("tlaLogoImage")));
    add(new Label("header_appname", appName));
    add(new Image("header_clarin_logo", new SharedResourceReference("clarinInvertedImage")));

    Link homePageLink = new Link("home_page_link") {
        @Override
        public void onClick() {
            final IndexPage resultPage = new IndexPage();
            setResponsePage(resultPage);
        }
    };
    homePageLink.add(new Image("home_image", new SharedResourceReference("homeImage")));
    add(homePageLink);

    final ModalWindow modalAbout = createAboutModalWindow();
    add(modalAbout);
    add(new AjaxLink<Void>("showModalAbout") {
        @Override
        public void onClick(AjaxRequestTarget art) {
            modalAbout.show(art);
        }
    });

    add(new ExternalLink("manual_link", Model.of(manualUrl)));

    add(new ExternalLink("register_link", Model.of(registerUrl)));

    add(new Label("header_username", new HeaderUsernameModel()));

    if ("anonymous".equals(LamusSession.get().getUserId())) {
        add(new ExternalLink("loginOrLogoutLink", "login",
                getLocalizer().getString("header_login_label", this)));
    } else {
        add(new ExternalLink("loginOrLogoutLink", "logout",
                getLocalizer().getString("header_logout_label", this)));
    }
}

From source file:ontopoly.components.ButtonFunctionBoxPanel.java

License:Apache License

protected Component getButton(String id) {

    AjaxLink<Object> button = new AjaxLink<Object>(id) {

        @Override//w ww  . j  a  v  a2  s .  c  om
        protected void onComponentTag(ComponentTag tag) {
            tag.setName("input");
            tag.put("type", "button");
            tag.put("value", getButtonLabel().getObject().toString());
            super.onComponentTag(tag);
        }

        @Override
        public void onClick(AjaxRequestTarget target) {
            ButtonFunctionBoxPanel.this.onClick(target);
        }
    };

    List<IBehavior> behaviors = getButtonBehaviors();
    if (behaviors != null) {
        Iterator<IBehavior> it = behaviors.iterator();
        while (it.hasNext()) {
            button.add(it.next());
        }
    }
    return button;
}

From source file:ontopoly.components.FieldInstanceCreatePlayerPanel.java

License:Apache License

public FieldInstanceCreatePlayerPanel(String id, FieldInstanceModel _fieldInstanceModel,
        FieldsViewModel fieldsViewModel, RoleFieldModel _roleFieldModel,
        AbstractFieldInstancePanel fieldInstancePanel, int createAction) {
    super(id);//ww w  .  java  2  s .co  m
    this.fieldInstanceModel = _fieldInstanceModel;
    this.fieldsViewModel = fieldsViewModel;
    this.roleFieldModel = _roleFieldModel;
    this.fieldInstancePanel = fieldInstancePanel;
    this.createAction = createAction;

    RoleField associationField = roleFieldModel.getRoleField();
    Collection<TopicType> allowedValueTypes = associationField
            .getAllowedPlayerTypes(_fieldInstanceModel.getFieldInstance().getInstance());
    if (allowedValueTypes.isEmpty()) {
        setVisible(false);
        OntopolyImageLink button = new OntopolyImageLink("button", "create.gif",
                new ResourceModel("icon.create.player")) {
            @Override
            public void onClick(AjaxRequestTarget target) {
            }
        };
        add(button);
        add(new Label("createMenu"));
        add(new Label("createModal"));
    } else if (allowedValueTypes.size() == 1) {
        this.topicTypeModel = new TopicTypeModel((TopicType) allowedValueTypes.iterator().next());
        OntopolyImageLink button = new OntopolyImageLink("button", "create.gif",
                new ResourceModel("icon.create.player")) {
            @Override
            public void onClick(AjaxRequestTarget target) {
                FieldInstanceCreatePlayerPanel.this.onClick(target, topicTypeModel.getTopicType());
            }
        };
        add(button);
        add(new Label("createMenu").setVisible(false));
        add(new Label("createModal").setVisible(false));
    } else {
        final String menuId = id + "_" + associationField.getId() + "_"
                + _fieldInstanceModel.getFieldInstance().getInstance().getId();
        Link<Object> button = new Link<Object>("button") {
            {
                add(new Image("image", new AbstractReadOnlyModel<ResourceReference>() {
                    @Override
                    public ResourceReference getObject() {
                        return new ResourceReference(ImageResource.class, "create.gif");
                    }
                }));
            }

            @Override
            protected void onComponentTag(ComponentTag tag) {
                super.onComponentTag(tag);
                tag.put("onclick", "menuItemPopup(this)");

                tag.put("id", "main" + menuId);
                tag.put("href", "#");
            }

            @Override
            public void onClick() {
            }
        };
        add(button);

        add(new ContextMenuPanel<TopicType>("createMenu", menuId) {
            @Override
            protected ListView<TopicType> createListView(final String menuId, final String menuItemId) {
                return new ListView<TopicType>(menuId,
                        new PlayerTypesModel(fieldInstanceModel, roleFieldModel)) {
                    @Override
                    public void populateItem(final ListItem<TopicType> item) {
                        AjaxLink<Object> createLink = new AjaxLink<Object>(menuItemId) {
                            @Override
                            public void onClick(AjaxRequestTarget target) {
                                FieldInstanceCreatePlayerPanel.this.onClick(target, item.getModelObject());
                            }
                        };
                        createLink.add(new Label("label", item.getModelObject().getName()));
                        item.add(createLink);
                    }
                };
            }
        });
        add(new Label("createModal").setVisible(false));
    }
}

From source file:ontopoly.pages.ModalFindPage.java

License:Apache License

public ModalFindPage(String id, FieldInstanceModel fieldInstanceModel, int activeTab) {
    super(id);/*  w  w  w .  j av  a2s.  com*/
    this.fieldInstanceModel = fieldInstanceModel;

    final WebMarkupContainer popupContent = new WebMarkupContainer("popupContent");
    popupContent.setOutputMarkupId(true);
    add(popupContent);

    FieldInstance fieldInstance = fieldInstanceModel.getFieldInstance();
    FieldAssignment fieldAssignment = fieldInstance.getFieldAssignment();
    RoleField roleField = (RoleField) fieldAssignment.getFieldDefinition();
    popupContent.add(new Label("title", new Model<String>(roleField.getFieldName())));

    final WebMarkupContainer searchTab = createSearchTab();
    popupContent.add(searchTab);

    final WebMarkupContainer browseTab = createBrowseTab();
    popupContent.add(browseTab);

    this.searchTabLink = new AjaxLink<Object>("searchTabLink") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            searchTab.setVisible(true);
            browseTab.setVisible(false);
            searchTabLink.setEnabled(false);
            browseTabLink.setEnabled(true);
            target.addComponent(popupContent);
        }
    };
    popupContent.add(searchTabLink);

    this.browseTabLink = new AjaxLink<Object>("browseTabLink") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            searchTab.setVisible(false);
            browseTab.setVisible(true);
            searchTabLink.setEnabled(true);
            browseTabLink.setEnabled(false);
            target.addComponent(popupContent);
        }
    };
    popupContent.add(browseTabLink);

    if (activeTab == ACTIVE_TAB_BROWSE) {
        searchTab.setVisible(false);
        browseTab.setVisible(true);
        searchTabLink.setEnabled(true);
        browseTabLink.setEnabled(false);
    } else {
        searchTab.setVisible(true);
        browseTab.setVisible(false);
        searchTabLink.setEnabled(false);
        browseTabLink.setEnabled(true);
    }

}

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

License:Open Source License

private void generateHideAllTooltipsLink(final String id) {
    this.add(new AjaxLink<Void>(id) {
        private static final long serialVersionUID = 1L;

        @Override// w  ww .ja  va  2s  .  co m
        public void onClick(final AjaxRequestTarget target) {
            target.appendJavaScript(BattlefieldService.HIDE_ALL_TOOLTIPS);
            target.appendJavaScript(BattlefieldService.HIDE_MENUS);
        }

    });
}

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   www.jav a 2s.  c o m
        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 void generateRevealHandLink(final String id) {
    this.add(new AjaxLink<Void>(id) {
        private static final long serialVersionUID = 1L;

        @Override/*  w w w  .  j  av a 2s  . com*/
        public void onClick(final AjaxRequestTarget target) {
            final Long _gameId = HomePage.this.session.getGameId();
            final List<BigInteger> allPlayersInGameExceptMe = HomePage.this.persistenceService
                    .giveAllPlayersFromGameExceptMe(_gameId, HomePage.this.session.getPlayer().getId());

            final NotifierCometChannel ncc = new NotifierCometChannel(NotifierAction.REVEAL_HAND, null, null,
                    HomePage.this.session.getPlayer().getName(), "", "", null, "");
            final ConsoleLogStrategy logger = AbstractConsoleLogStrategy.chooseStrategy(
                    ConsoleLogType.REVEAL_HAND, null, null, null, null,
                    HomePage.this.session.getPlayer().getName(), null, null, null, Boolean.FALSE, _gameId);
            final RevealHandCometChannel rhcc = new RevealHandCometChannel(_gameId,
                    HomePage.this.session.getPlayer().getId(),
                    HomePage.this.session.getPlayer().getDeck().getDeckId());
            EventBusPostService.post(allPlayersInGameExceptMe, ncc, new ConsoleLogCometChannel(logger), rhcc);

            final List<BigInteger> playerToWhomToSend = new ArrayList<>();
            playerToWhomToSend.add(BigInteger.valueOf(HomePage.this.session.getPlayer().getId().longValue()));
            EventBusPostService.post(playerToWhomToSend, ncc, new ConsoleLogCometChannel(logger));
        }

    });
}

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

License:Open Source License

private void generateEndMatchLink(final String id) {
    this.add(new AjaxLink<Void>(id) {
        private static final long serialVersionUID = 1L;

        @Override/*from  w w w . j  av  a  2 s .  c  o  m*/
        public void onClick(final AjaxRequestTarget target) {
            HomePage.LOGGER.info("end match");
            target.appendJavaScript(
                    "var r = confirm('Are you sure that you want to end this match?'); if (r==true) { window.location = window.location + '?endMatch=true'; }; ");
        }
    });
}