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

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

Introduction

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

Prototype

public AbstractLink setBody(final IModel<?> bodyModel) 

Source Link

Document

Sets the link's body model

Usage

From source file:org.devgateway.eudevfin.projects.module.components.panels.ResultsTableListPanel.java

@Override
protected void populateTable() {
    final ModalWindow modal = AddModalWindow(null);

    this.itemsListView = new ListView<ProjectResult>("projectResultList", items) {

        private static final long serialVersionUID = -8758662617501215830L;

        @Override// w  w w .ja  v a2  s  . c o m
        protected void populateItem(ListItem<ProjectResult> listItem) {
            final ProjectResult result = listItem.getModelObject();

            AjaxLink linkToEdit = new AjaxLink("linkToEditResult") {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    PageParameters parameters = new PageParameters().add(ResultsTableModal.PARAM_RESULT_ID,
                            result.getId());
                    setParameters(parameters);
                    AddModalWindow(parameters);
                    modal.show(target);
                }
            };

            linkToEdit.setBody(Model.of(result.getResult()));
            String statusName = new StringResourceModel(result.getStatus(), ResultsTableListPanel.this, null)
                    .getString();
            Label statusLabel = new Label("status", statusName);
            Label descriptionLabel = new Label("description", result.getDescription());

            listItem.add(statusLabel);
            listItem.add(descriptionLabel);
            listItem.add(linkToEdit);
        }
    };
    itemsListView.setOutputMarkupId(true);
    this.add(modal);
    this.add(itemsListView);

}

From source file:org.devgateway.eudevfin.projects.module.components.panels.TransactionTableListPanel.java

@Override
protected void populateTable() {
    final ModalWindow modal = AddModalWindow(null);
    //        refreshItems();
    this.itemsListView = new ListView<FinancialTransaction>("projectTransactionsList", items) {

        private static final long serialVersionUID = -8758662617501215830L;

        @Override//from   w w  w  . ja v a2s  .c  o  m
        protected void populateItem(ListItem<FinancialTransaction> listItem) {
            final FinancialTransaction transaction = listItem.getModelObject();

            AjaxLink linkToEdit = new AjaxLink("linkToEditTransaction") {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    PageParameters parameters = new PageParameters()
                            .add(TransactionsTableModal.PARAM_TRANSACTION_ID, transaction.getId());
                    setParameters(parameters);
                    AddModalWindow(parameters);
                    modal.show(target);
                }
            };
            linkToEdit.setBody(Model.of(transaction.getShortDescription()));
            String CRSId = transaction.getCrsIdentificationNumber() == null ? ""
                    : transaction.getCrsIdentificationNumber();
            Label CRSIdLabel = new Label("CRSId", CRSId);
            String geographicName = transaction.getRecipient() == null ? ""
                    : transaction.getRecipient().getName();
            Label geographicFocusLabel = new Label("geographicFocus", geographicName);
            String agencyName = transaction.getExtendingAgency() == null ? ""
                    : transaction.getExtendingAgency().getName();
            Label financingInstitutionLabel = new Label("financingInstitution", agencyName);
            Label reportingYearLabel = new Label("reportingYear", transaction.getReportingYear().getYear());

            final CustomFinancialTransaction ctx = (CustomFinancialTransaction) transaction;
            Label amountUSD = new Label("amountUSD",
                    RateUtil.moneyToString(rateUtil.exchange(transaction.getAmountsExtended(), CurrencyUnit.USD,
                            ctx.getFixedRate(), RateUtil.getStartOfMonth(ctx.getCommitmentDate()))));
            Label amountRON = new Label("amountRON", transaction.getAmountsExtended().getAmount().toString());
            Label amountEUR = new Label("amountEUR",
                    RateUtil.moneyToString(rateUtil.exchange(transaction.getAmountsExtended(), CurrencyUnit.EUR,
                            ctx.getFixedRate(), RateUtil.getStartOfMonth(ctx.getCommitmentDate()))));

            BootstrapDeleteButton delete = new BootstrapDeleteButton("delete",
                    new StringResourceModel("delete", this, null)) {
                @Override
                protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
                    NewProjectPage.project.removeTransaction(transaction);
                    TransactionTableListPanel newComp = new TransactionTableListPanel(WICKETID_LIST_PANEL,
                            new ProjectTransactionsListGenerator(
                                    NewProjectPage.project.getProjectTransactions()));
                    newComp.add(new AttributeAppender("class", "budget-table"));
                    TransactionTableListPanel.this.replaceWith(newComp);
                    target.add(newComp);
                }
            };

            delete.add(AttributeModifier.remove("class"));
            delete.add(AttributeModifier.prepend("class", "round_delete"));

            listItem.add(linkToEdit);
            listItem.add(CRSIdLabel);
            listItem.add(geographicFocusLabel);
            listItem.add(financingInstitutionLabel);
            listItem.add(reportingYearLabel);
            listItem.add(amountUSD);
            listItem.add(amountRON);
            listItem.add(amountEUR);
            listItem.add(delete);
        }
    };
    itemsListView.setOutputMarkupId(true);
    this.add(modal);
    this.add(itemsListView);

}