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:com.comcast.cdn.traffic_control.traffic_monitor.wicket.components.CacheListPanel.java

License:Apache License

private ListView<String> createServerListView(final Behavior updater, final ModalWindow modalWindow) {
    return new ListView<String>("servers", getServerList()) {
        private static final long serialVersionUID = 1L;

        @Override//w  w  w.  j a  v a  2 s. com
        protected void populateItem(final ListItem<String> item) {
            final String cacheName = item.getModelObject();

            item.add(new UpdatingAttributeAppender("class", new Model<String>("") {
                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    final CacheState cs = CacheState.getState(cacheName);

                    if (cs != null && !cs.isAvailable()) {
                        final String status = cs.getLastValue(HealthDeterminer.STATUS);

                        if (status != null) {
                            switch (HealthDeterminer.AdminStatus.valueOf(status)) {
                            case ADMIN_DOWN:
                            case OFFLINE:
                                return "warning";
                            default:
                                return "error";
                            }
                        } else {
                            return "error";
                        }
                    } else {
                        return " ";
                    }
                }
            }, " "));
            item.add(updater);

            Label label = new Label("status", new CacheStateModel(cacheName, "_status_string_"));
            label.add(updater);
            item.add(label);
            label = new Label("loadavg", new CacheStateModel(cacheName, "loadavg"));
            label.add(updater);
            item.add(label);
            label = new Label("queryTime", new CacheStateModel(cacheName, "queryTime"));
            label.add(updater);
            item.add(label);
            label = new Label("kbps", new CacheStateModel(cacheName, "kbps"));
            label.add(updater);
            item.add(label);
            label = new Label("maxKbps", new CacheStateModel(cacheName, "maxKbps"));
            label.add(updater);
            item.add(label);
            label = new Label("current_client_connections",
                    new CacheStateModel(cacheName, "ats.proxy.process.http.current_client_connections"));
            label.add(updater);
            item.add(label);

            //            final PageParameters pars = new PageParameters();
            //            pars.add("hostname", cacheName);
            //            final BookmarkablePageLink<Object> link 
            //               = new BookmarkablePageLink<Object>("fulldetails", FullDetailsPage.class, pars);
            final AjaxLink<Void> link = new AjaxLink<Void>("fulldetails") {
                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(final AjaxRequestTarget target) {
                    hostname = cacheName;
                    modalWindow.show(target);
                }
            };
            link.setBody(new Model<String>(cacheName));
            item.add(link);
        }
    };
}

From source file:com.comcast.cdn.traffic_control.traffic_monitor.wicket.components.DsListPanel.java

License:Apache License

private ListView<String> createDsListView(final Behavior updater, final ModalWindow modalWindow) {
    return new ListView<String>("ds", getDsList()) {
        private static final long serialVersionUID = 1L;

        @Override//from  ww  w  .  j a v a2s .  c om
        protected void populateItem(final ListItem<String> item) {
            final String dsName = item.getModelObject();

            item.add(new UpdatingAttributeAppender("class", new Model<String>("") {
                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    //                  if ( cacheState.isError() ) return "error";
                    final DsState cs = DsState.get(dsName);
                    if (cs != null && !cs.isAvailable()) {
                        return "error";
                    } // "grey"
                    else {
                        return " ";
                    }
                }
            }, " "));
            item.add(updater);

            Label label = new Label("status", new DsStateModel(dsName, "_status_string_"));
            label.add(updater);
            item.add(label);
            label = new Label("kbps", new DsStateModel(dsName, "total.kbps"));
            label.add(updater);
            item.add(label);
            label = new Label("tps", new DsStateModel(dsName, "total.tps_total"));
            label.add(updater);
            item.add(label);
            label = new Label("disabled", new DsStateModel(dsName, "disabledLocations"));
            label.add(updater);
            item.add(label);

            label = new Label("caches-reporting", new DsStateModel(dsName, "caches-reporting"));
            label.add(updater);
            item.add(label);
            label = new Label("caches-available", new DsStateModel(dsName, "caches-available"));
            label.add(updater);
            item.add(label);
            label = new Label("caches-configured", new DsStateModel(dsName, "caches-configured"));
            label.add(updater);
            item.add(label);

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

                @Override
                public void onClick(final AjaxRequestTarget target) {
                    dsId = dsName;
                    modalWindow.show(target);
                }
            };
            link.setBody(new Model<String>(dsName));
            item.add(link);
        }
    };
}

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;//www .  j  a v a  2 s . 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.AjaxLinkPage.java

License:Apache License

public AjaxLinkPage() {
    super();// w w w. j av a 2 s. co  m
    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.backoffice.web.report.Reports.java

License:Open Source License

public Reports(PageParameters params) {
    add(new AjaxLink<String>("openAccounts") {
        private static final long serialVersionUID = 1L;

        @Override/*w  w  w  .jav a 2s .  c o  m*/
        public void onClick(AjaxRequestTarget target) {
            ListAccountsRequest request = new ListAccountsRequest();
            request.setStatus(AccountStatus.OPEN);
            request.setOffset(0);
            request.setLimit(1000);
            request.setSortOrder(AccountsOrder.CREATION_DATE);
            request.setAscending(true);

            AccountQueryResult accountsResult = walletService.listAccounts(request);
            ArrayList<AccountHolder> accounts = new ArrayList<AccountHolder>();

            for (Account a : accountsResult.getAccounts()) {
                BigDecimal balance = BigDecimal.ZERO;
                try {
                    balance = walletService.getAccountBalance(a.getId()).getBalance().getAmount();
                } catch (AccountNotFoundException e) {
                    // do nothing
                }
                accounts.add(new AccountHolder(a, balance));
            }

            HttpServletRequest req = ((ServletWebRequest) getRequest()).getContainerRequest();
            req.getSession().setAttribute(ReportServlet.REPORTS_COLLECTION_DATA_SOURCE, accounts);

            String url = getRequest().getContextPath() + "/reportbuilder/reports/open accounts?format=pdf";
            target.appendJavaScript("document.location = '" + url + "'");
        }
    }.setVisible(false));

    add(new AjaxLink<String>("userCount") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            UserQueryResult usersResult = userService.findUsers(null, null, 0, 10000, null, true);
            Map<Long, Long> operatorUserCount = new HashMap<Long, Long>();
            for (User u : usersResult.getUsers()) {
                Long count = operatorUserCount.get(u.getOperatorId());
                count = count == null ? 0l : count + 1;
                operatorUserCount.put(u.getOperatorId(), count);
            }
            HttpServletRequest request = ((ServletWebRequest) getRequest()).getContainerRequest();
            request.getSession().setAttribute(ReportServlet.REPORTS_COLLECTION_DATA_SOURCE,
                    operatorUserCount.entrySet());

            String url = getRequest().getContextPath() + "/reportbuilder/reports/users by operator?format=pdf";
            target.appendJavaScript("document.location = '" + url + "'");
        }
    });
}

From source file:com.cubeia.backoffice.web.user.UserList.java

License:Open Source License

/**
* Constructor that is invoked when page is invoked without a session.
* 
* @param parameters//from  ww w .  jav  a2s .c  o m
*            Page parameters
*/
public UserList(final PageParameters parameters) {
    final Form<?> searchForm = new Form<UserList>("searchForm", new CompoundPropertyModel<UserList>(this));
    final TextField<String> idField = new TextField<String>("userId");
    searchForm.add(idField);
    final TextField<String> userNameField = new TextField<String>("name");
    searchForm.add(userNameField);
    searchForm.add(new Button("clearForm") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onSubmit() {
            super.onSubmit();
            idField.clearInput();
            userNameField.clearInput();
        }
    });
    add(searchForm);
    add(new FeedbackPanel("feedback"));

    final UsersDataProvider dataProvider = new UsersDataProvider();
    List<IColumn<User, String>> columns = new ArrayList<IColumn<User, String>>();

    columns.add(new AbstractColumn<User, String>(Model.of("User Id")) {
        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<User>> item, String componentId, IModel<User> model) {
            Long userId = model.getObject().getUserId();
            LabelLinkPanel panel = new LabelLinkPanel(componentId, "" + userId, UserSummary.class,
                    params(UserSummary.PARAM_USER_ID, userId));
            item.add(panel);
        }

        @Override
        public boolean isSortable() {
            return true;
        }

        @Override
        public String getSortProperty() {
            return UserOrder.ID.name();
        }
    });
    columns.add(new PropertyColumn<User, String>(Model.of("XId"), "externalUserId"));
    columns.add(
            new PropertyColumn<User, String>(Model.of("User name"), UserOrder.USER_NAME.name(), "userName"));
    columns.add(new PropertyColumn<User, String>(Model.of("Status"), UserOrder.STATUS.name(), "status"));
    //        columns.add(new PropertyColumn<User,String>(Model.of("First name"), "userInformation.firstName"));
    //        columns.add(new PropertyColumn<User,String>(Model.of("Last name"), "userInformation.lastName"));
    //        columns.add(new PropertyColumn<User,String>(Model.of("Country"), UserOrder.COUNTRY.name(), "userInformation.country"));
    columns.add(new PropertyColumn<User, String>(Model.of("Ext. Username"), "attributes.externalUsername"));
    columns.add(new PropertyColumn<User, String>(Model.of("Screename"), "attributes.screenname"));

    AjaxFallbackDefaultDataTable<User, String> userTable = new AjaxFallbackDefaultDataTable<User, String>(
            "userTable", columns, dataProvider, 20);
    add(userTable);

    final ModalWindow modal = new ModalWindow("modal");
    modal.setContent(new UserReportPanel(modal.getContentId(), modal));
    modal.setTitle("Generate report");
    modal.setCookieName("modal");
    modal.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    modal.setInitialWidth(265);
    modal.setInitialHeight(200);

    add(modal);
    add(new AjaxLink<Void>("showReportPanel") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            List<User> users = getUserList(getUserId(), getName(), 0, Integer.MAX_VALUE,
                    dataProvider.getSort().getProperty(), dataProvider.getSort().isAscending()).getUsers();
            HttpServletRequest request = (HttpServletRequest) getRequest().getContainerRequest();
            request.getSession().setAttribute(ReportServlet.REPORTS_COLLECTION_DATA_SOURCE, users);
            modal.show(target);
        }
    });
}

From source file:com.cubeia.games.poker.admin.wicket.pages.report.Reports.java

License:Open Source License

public Reports(PageParameters params) {
    super(params);
    add(new AjaxLink<String>("openAccounts") {
        private static final long serialVersionUID = 1L;

        @Override/*from  ww  w.j  av a2  s  .  c  om*/
        public void onClick(AjaxRequestTarget target) {
            ListAccountsRequest request = new ListAccountsRequest();
            request.setStatus(AccountStatus.OPEN);
            request.setOffset(0);
            request.setLimit(1000);
            request.setSortOrder(AccountsOrder.CREATION_DATE);
            request.setAscending(true);

            AccountQueryResult accountsResult = walletService.listAccounts(request);
            ArrayList<AccountHolder> accounts = new ArrayList<AccountHolder>();

            for (Account a : accountsResult.getAccounts()) {
                BigDecimal balance = BigDecimal.ZERO;
                try {
                    balance = walletService.getAccountBalance(a.getId()).getBalance().getAmount();
                } catch (AccountNotFoundException e) {
                    // do nothing
                }
                accounts.add(new AccountHolder(a, balance));
            }

            HttpServletRequest req = ((ServletWebRequest) getRequest()).getContainerRequest();
            req.getSession().setAttribute(ReportServlet.REPORTS_COLLECTION_DATA_SOURCE, accounts);

            String url = getRequest().getContextPath() + "/reportbuilder/reports/open accounts?format=pdf";
            target.appendJavaScript("document.location = '" + url + "'");
        }
    }.setVisible(false));

    add(new AjaxLink<String>("userCount") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            UserQueryResult usersResult = userService.findUsers(null, null, 0, 10000, null, true);
            Map<Long, Long> operatorUserCount = new HashMap<Long, Long>();
            for (User u : usersResult.getUsers()) {
                Long count = operatorUserCount.get(u.getOperatorId());
                count = count == null ? 0l : count + 1;
                operatorUserCount.put(u.getOperatorId(), count);
            }
            HttpServletRequest request = ((ServletWebRequest) getRequest()).getContainerRequest();
            request.getSession().setAttribute(ReportServlet.REPORTS_COLLECTION_DATA_SOURCE,
                    operatorUserCount.entrySet());

            String url = getRequest().getContextPath() + "/reportbuilder/reports/users by operator?format=pdf";
            target.appendJavaScript("document.location = '" + url + "'");
        }
    });
}

From source file:com.cubeia.games.poker.admin.wicket.pages.user.UserList.java

License:Open Source License

/**
* Constructor that is invoked when page is invoked without a session.
* 
* @param parameters/* w w  w.  ja  v  a  2  s  . co m*/
*            Page parameters
*/
public UserList(final PageParameters parameters) {
    super(parameters);
    final Form<?> searchForm = new Form<UserList>("searchForm", new CompoundPropertyModel<UserList>(this));
    final TextField<String> idField = new TextField<String>("userId");
    searchForm.add(idField);
    final TextField<String> userNameField = new TextField<String>("name");
    searchForm.add(userNameField);
    searchForm.add(new Button("clearForm") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onSubmit() {
            super.onSubmit();
            idField.clearInput();
            userNameField.clearInput();
        }
    });
    add(searchForm);
    add(new FeedbackPanel("feedback"));

    final UsersDataProvider dataProvider = new UsersDataProvider();
    List<IColumn<User, String>> columns = new ArrayList<IColumn<User, String>>();

    columns.add(new AbstractColumn<User, String>(Model.of("User Id")) {
        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<User>> item, String componentId, IModel<User> model) {
            Long userId = model.getObject().getUserId();
            LabelLinkPanel panel = new LabelLinkPanel(componentId, "" + userId, UserSummary.class,
                    params(UserSummary.PARAM_USER_ID, userId));
            item.add(panel);
        }

        @Override
        public boolean isSortable() {
            return true;
        }

        @Override
        public String getSortProperty() {
            return UserOrder.ID.name();
        }
    });
    columns.add(new PropertyColumn<User, String>(Model.of("XId"), "externalUserId"));
    columns.add(
            new PropertyColumn<User, String>(Model.of("User name"), UserOrder.USER_NAME.name(), "userName"));
    columns.add(new PropertyColumn<User, String>(Model.of("Status"), UserOrder.STATUS.name(), "status"));
    //        columns.add(new PropertyColumn<User,String>(Model.of("First name"), "userInformation.firstName"));
    //        columns.add(new PropertyColumn<User,String>(Model.of("Last name"), "userInformation.lastName"));
    //        columns.add(new PropertyColumn<User,String>(Model.of("Country"), UserOrder.COUNTRY.name(), "userInformation.country"));
    columns.add(new PropertyColumn<User, String>(Model.of("Ext. Username"), "attributes.externalUsername"));
    columns.add(new PropertyColumn<User, String>(Model.of("Screename"), "attributes.screenname"));

    AjaxFallbackDefaultDataTable<User, String> userTable = new AjaxFallbackDefaultDataTable<User, String>(
            "userTable", columns, dataProvider, 20);
    add(userTable);

    final ModalWindow modal = new ModalWindow("modal");
    modal.setContent(new UserReportPanel(modal.getContentId(), modal));
    modal.setTitle("Generate report");
    modal.setCookieName("modal");
    modal.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    modal.setInitialWidth(265);
    modal.setInitialHeight(200);

    add(modal);
    add(new AjaxLink<Void>("showReportPanel") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            List<User> users = getUserList(getUserId(), getName(), 0, Integer.MAX_VALUE,
                    dataProvider.getSort().getProperty(), dataProvider.getSort().isAscending()).getUsers();
            HttpServletRequest request = (HttpServletRequest) getRequest().getContainerRequest();
            request.getSession().setAttribute(ReportServlet.REPORTS_COLLECTION_DATA_SOURCE, users);
            modal.show(target);
        }
    });
}

From source file:com.doculibre.constellio.wicket.links.SignInLinkHolder.java

License:Open Source License

@Override
public WebMarkupContainer newLink(String id) {
    return new AjaxLink(id) {
        @Override//from  www .java  2  s.c  om
        public void onClick(AjaxRequestTarget target) {
            ModalWindow modalWindow = getModalWindow();
            modalWindow.setContent(new ConstellioSignInPanel(modalWindow.getContentId()));
            modalWindow.show(target);
        }
    };
}

From source file:com.doculibre.constellio.wicket.panels.admin.analyzer.AddEditAnalyzerFieldPanel.java

License:Open Source License

public AddEditAnalyzerFieldPanel(String id, IModel analyzerModel) {
    super(id, new CompoundPropertyModel(analyzerModel));

    Analyzer analyzer = (Analyzer) analyzerModel.getObject();
    filtersModel.getObject().addAll(analyzer.getFilters());

    final ModalWindow analyzerClassModal = new ModalWindow("analyzerClassModal");
    add(analyzerClassModal);// w  ww  .  ja v a2 s.  c o  m
    analyzerClassModal.setCssClassName(ModalWindow.CSS_CLASS_GRAY);

    IModel analyzerClassesModel = new LoadableDetachableModel() {
        @Override
        protected Object load() {
            AnalyzerClassServices analyzerClassServices = ConstellioSpringUtils.getAnalyzerClassServices();
            return analyzerClassServices.list();
        }
    };

    IChoiceRenderer analyzerClassRenderer = new ChoiceRenderer("className");

    final DropDownChoice analyzerClassField = new DropDownChoice("analyzerClass", analyzerClassesModel,
            analyzerClassRenderer);
    add(analyzerClassField);
    analyzerClassField.setOutputMarkupId(true);

    AjaxLink addAnalyzerClassLink = new AjaxLink("addAnalyzerClassLink") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            AddEditAnalyzerClassPanel addEditAnalyzerClassPanel = new AddEditAnalyzerClassPanel(
                    analyzerClassModal.getContentId(), new AnalyzerClass(), analyzerClassField);
            analyzerClassModal.setContent(addEditAnalyzerClassPanel);
            analyzerClassModal.show(target);
        }
    };
    add(addAnalyzerClassLink);

    final ModalWindow tokenizerClassModal = new ModalWindow("tokenizerClassModal");
    add(tokenizerClassModal);
    tokenizerClassModal.setCssClassName(ModalWindow.CSS_CLASS_GRAY);

    IModel tokenizerClassesModel = new LoadableDetachableModel() {
        @Override
        protected Object load() {
            TokenizerClassServices tokenizerClassServices = ConstellioSpringUtils.getTokenizerClassServices();
            return tokenizerClassServices.list();
        }
    };

    IChoiceRenderer tokenizerClassRenderer = new ChoiceRenderer("className");

    final DropDownChoice tokenizerClassField = new DropDownChoice("tokenizerClass", tokenizerClassesModel,
            tokenizerClassRenderer);
    add(tokenizerClassField);
    tokenizerClassField.setOutputMarkupId(true);

    AjaxLink addTokenizerClassLink = new AjaxLink("addTokenizerClassLink") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            AddEditTokenizerClassPanel addEditTokenizerClassPanel = new AddEditTokenizerClassPanel(
                    tokenizerClassModal.getContentId(), new TokenizerClass(), tokenizerClassField);
            tokenizerClassModal.setContent(addEditTokenizerClassPanel);
            tokenizerClassModal.show(target);
        }
    };
    add(addTokenizerClassLink);

    add(new FilterListPanel("filtersPanel"));
}