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:eu.uqasar.web.pages.tree.subset.SubsetProposalPage.java

License:Apache License

public SubsetProposalPage(PageParameters parameters) {
    super(parameters);
    subsetProposalPanel = new SubsetProposalPanel("subsetPanel");
    add(subsetProposalPanel);/*from w w  w  .j a va2  s . c  o m*/

    saveSelectedButton = new AjaxLink("saveSelected") {
        private static final long serialVersionUID = -3695540884955827907L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (subsetProposalPanel.getDataGroup().getModelObject().isEmpty()) {
                // Prints error message when no element has been selected
                getPage().error(new StringResourceModel("subset.no.selection", this, null).getString());
                target.add(feedbackPanel);
            } else {
                // opens the modal to Confirm that the new project will be created from the selected items
                saveConfirmationModal.appendShowDialogJavaScript(target);
                System.out.println("Hola");
            }
        }
    };
    add(saveSelectedButton);

    // add confirmation modal to confirm creating items
    add(saveConfirmationModal = newSaveConfirmationModal());

}

From source file:gr.abiss.calipso.wicket.asset.ItemAssetsPanel.java

License:Open Source License

private WebMarkupContainer renderAssetCodeFilter() {
    WebMarkupContainer assetCodeContainer = new WebMarkupContainer("assetCodeContainer");
    //      AssetFilter assetFilter = new AssetFilter();
    final CompoundPropertyModel assetFilterModel = new CompoundPropertyModel(new AssetFilter());

    //Label//  w w w .j  a v  a  2s. c o m
    WebMarkupContainer assetCodeLabel = new WebMarkupContainer("assetCodeLabel");

    //Asset Code
    final TextField assetCode = new TextField("assetCode", new PropertyModel(assetFilter, "assetCode")) {

    };
    assetCode.setOutputMarkupId(true);

    //TODO: Implement filter asset by Inventory Code
    //Button
    AjaxLink submitAssetCode = new AjaxLink("submitAssetCode") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            target.addComponent(assetCode);
        }
    };
    submitAssetCode.setOutputMarkupId(true);

    assetCodeContainer.add(assetCodeLabel);
    assetCodeContainer.add(assetCode);
    assetCodeContainer.add(submitAssetCode);

    return assetCodeContainer;
}

From source file:gr.abiss.calipso.wicket.asset.ItemFormAssetSearchPanel.java

License:Open Source License

public ItemFormAssetSearchPanel(String id, AssetSearch as) {
    super(id);//  w  w w  .  j  av a 2  s. c  o  m
    this.setOutputMarkupId(true);
    this.setVisible(true);
    final AssetSearch assetSearch = as;
    this.setDefaultModel(new CompoundPropertyModel(assetSearch));

    final WebMarkupContainer assetSearchForm = new WebMarkupContainer("assetAjaxSearchForm");
    assetSearchForm.setOutputMarkupId(true);
    add(assetSearchForm);
    assetSearchForm.add(new AjaxLink("close") {

        @Override
        public void onClick(AjaxRequestTarget target) {
            closePanel(target);
        }

    });
    // inventory code
    final TextField inventoryCode = new TextField("asset.inventoryCode");
    inventoryCode.setLabel(new ResourceModel("asset.inventoryCode"));
    inventoryCode.add(new AjaxFormComponentUpdatingBehavior("onchange") {
        protected void onUpdate(AjaxRequestTarget target) {
            // Reset the inventoryCode model dropdown when the vendor changes
            assetSearch.getAsset().setInventoryCode(inventoryCode.getDefaultModelObjectAsString());
        }
    });
    assetSearchForm.add(inventoryCode);
    assetSearchForm.add(new SimpleFormComponentLabel("assetInventoryCodeLabel", inventoryCode));

    AssetSearchDataProvider assetSearchDataProvider = new AssetSearchDataProvider(assetSearch);
    // if AssetSearch only addresses one AssetType, do not allow other choices
    List<AssetType> assetTypes = null;
    if (assetSearch.getAsset().getAssetType() != null) {
        assetTypes = new ArrayList<AssetType>(1);
        assetTypes.add(assetSearch.getAsset().getAssetType());
    } else {
        assetTypes = getCalipso().findAllAssetTypes();
    }
    @SuppressWarnings("serial")
    final DropDownChoice assetTypeChoice = new DropDownChoice("asset.assetType", assetTypes,
            new IChoiceRenderer() {
                public Object getDisplayValue(Object o) {
                    return localize(((AssetType) o).getNameTranslationResourceKey());
                }

                public String getIdValue(Object o, int i) {
                    return localize(((AssetType) o).getName());
                }
            });
    if (assetTypes.size() == 1) {
        logger.debug("Only allow one Asset TypeChoice");
        assetTypeChoice.setNullValid(false).setRequired(true);
    } else {
        logger.debug("Only any AssetType Choice");
    }

    // List view headers 
    List<String> columnHeaders = assetSearch.getColumnHeaders();

    ListView headings = new ListView("headings", columnHeaders) {

        private static final long serialVersionUID = 1L;

        protected void populateItem(ListItem listItem) {
            final String header = (String) listItem.getModelObject();
            AjaxLink headingLink = new AjaxLink("heading") {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    assetSearch.doSort(header);
                    target.addComponent(ItemFormAssetSearchPanel.this);
                }
            };

            listItem.add(headingLink);
            String label = localize("asset.assetsList." + header);
            headingLink.add(new Label("heading", label));
            if (header.equals(assetSearch.getSortFieldName())) {
                String order = assetSearch.isSortDescending() ? "order-down" : "order-up";
                listItem.add(new SimpleAttributeModifier("class", order));
            }
        }
    };
    assetSearchForm.add(headings);

    //Header message 
    Label hAction = new Label("hAction");
    hAction.setDefaultModel(new Model(localize("edit")));
    assetSearchForm.add(hAction);

    // the DataView with the results of the search
    final AssetsDataView assetDataView = new AssetsDataView("assetDataView", assetSearchDataProvider,
            getBreadCrumbModel(), getCalipso().getRecordsPerPage()) {

        // when click the add button
        @Override
        public void onAddAssetClick(Asset asset, AjaxRequestTarget target) {
            // re-render
            onAssetSelect(asset, target);
        }
    };
    assetSearchForm.add(assetDataView);

    AjaxPagingNavigator panelNavigator = new AjaxPagingNavigator("navigator", assetDataView) {
        @Override
        protected void onAjaxEvent(AjaxRequestTarget target) {
            target.addComponent(ItemFormAssetSearchPanel.this);
        }
    };
    assetSearchForm.add(panelNavigator);

    // back to our asset type choice....
    assetSearchForm.add(assetTypeChoice);
    assetTypeChoice.setLabel(new ResourceModel("asset.assetType"));
    // Add Ajax Behaviour...
    assetTypeChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {
        protected void onUpdate(AjaxRequestTarget target) {
            // Reset the phone model dropdown when the vendor changes
            assetDataView.setCurrentPage(0);
            assetSearch.getAsset().setAssetType((AssetType) assetTypeChoice.getModelObject());
        }
    });
    assetSearchForm.add(new SimpleFormComponentLabel("assetTypeLabel", assetTypeChoice));
    AjaxLink submitLink = new AjaxLink("submit") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            //assetSearchForm.replace(getConfiguredAssetListPanel(assetSearch));
            target.addComponent(ItemFormAssetSearchPanel.this);
        }
    };
    assetSearchForm.add(submitLink);
}

From source file:gr.abiss.calipso.wicket.asset.ItemFormAssetSearchPanel.java

License:Open Source License

/**
 * @param assetSearch//from  www  .  ja v a 2  s.co  m
 * @return
 */

private AssetsListPanel getConfiguredAssetListPanel(final AssetSearch assetSearch) {
    // override AssetsListPanel's getAssetActionLink to add the asset
    AssetsListPanel assetListPanel = new AssetsListPanel("assetsListPanel", getBreadCrumbModel(), assetSearch) {
        public AbstractLink getAssetActionLink(String markupId, final Asset asset) {
            AjaxLink link = new AjaxLink(markupId) {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    onAssetSelect(asset, target);
                }
            };
            link.add(new StaticImage("actionLinkImg", new Model("../resources/add.gif")));
            return link;
        }
    };
    assetListPanel.setOutputMarkupId(true);
    return assetListPanel;
}

From source file:gr.abiss.calipso.wicket.components.assets.AssetsDataView.java

License:Open Source License

/**
 * @see org.apache.wicket.markup.repeater.RefreshingView#populateItem(org.apache.wicket.markup.repeater.Item)
 *//*from   ww w .j a v a2  s.c  o  m*/
@Override
protected void populateItem(Item item) {
    final Asset asset = (Asset) item.getModelObject();

    if (item.getIndex() % 2 != 0) {
        item.add(sam);
    }

    item.add(new Label("typeLabel",
            this.getLocalizer().getString(asset.getAssetType().getNameTranslationResourceKey(), this)));

    // expanded link
    // to be sure that will work for all cases
    // even if no breadCrumbModel exists
    /*if(breadCrumbModel != null){
       ExpandCustomAttributesLink expandCustomAttributesLink = 
    new ExpandCustomAttributesLink("expandCustomAttributesLink", breadCrumbModel, asset);
       item.add(expandCustomAttributesLink);
    }else{
       item.add(new WebMarkupContainer("expandCustomAttributesLink").setVisible(false).setRenderBodyOnly(true));
    }*/

    item.add(new Label("inventoryCodeLabel", new Model(asset.getInventoryCode())));
    // SimpleDateFormat to convert Date object to String
    SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");

    Date supportStartDate = asset.getSupportStartDate();
    String startDate = (asset.getSupportStartDate() != null) ? df.format(supportStartDate) : "";
    item.add(new Label("supportStartDateLabel", new Model(startDate)));

    Date supportEndDate = asset.getSupportEndDate();
    String endDate = (supportEndDate != null) ? df.format(supportEndDate) : "";
    item.add(new Label("supportEndDateLabel", new Model(endDate)));

    // space
    item.add(new Label("spacenameLabel",
            this.getLocalizer().getString(asset.getSpace().getNameTranslationResourceKey(), this)));

    item.add(new AjaxLink("add") {

        @Override
        public void onClick(AjaxRequestTarget target) {
            onAddAssetClick(asset, target);
        }

    });
}

From source file:gr.abiss.calipso.wicket.components.user.UserDataView.java

License:Open Source License

/**
 * @see org.apache.wicket.markup.repeater.RefreshingView#populateItem(org.apache.wicket.markup.repeater.Item)
 *///from w ww. ja  v  a 2 s  . c  o m
@Override
protected void populateItem(final Item item) {
    final User user = (User) item.getModelObject();
    setDefaultModel(new CompoundPropertyModel(user));

    if (item.getIndex() % 2 != 0) {
        item.add(sam);
    }

    item.add(new Label("name", user.getName()));

    item.add(new Label("lastname", user.getLastname()));

    item.add(new Label("loginName", user.getLoginName()));

    String strOrganization;
    if (user.getOrganization() != null) {
        strOrganization = user.getOrganization().getName();
    } else {

        strOrganization = "";
    }

    item.add(new Label("organization", strOrganization));

    item.add(new Label("email", user.getEmail()));

    item.add(new Label("address", user.getAddress()));

    item.add(new Label("country", this.getLocalizer().getString("country." + user.getCountry().getId(), this)));

    item.add(new Label("phone", user.getPhone()));

    item.add(new AjaxLink("select") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            onAddingUser(user, target);
            item.add(selected);
        }
    });
}

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

License:Open Source License

private void addAggregates(final ItemSearch itemSearch) {
    boolean showAgregates = !getPrincipal().isAnonymous() && itemSearch.getSpace() != null;
    //if(!getPrincipal().isAnonymous() && itemSearch.getSpace() != null){
    final ModalWindow agregatesReportModal = new ModalWindow("agregatesReportModal");
    add(agregatesReportModal);/*from  w w w . j  a  v a 2 s  . c  o  m*/
    //modal2.setCookieName("modal-2");
    WebMarkupContainer agregatesContainer = new WebMarkupContainer("agregatesContainer");
    AjaxLink agregatesReportLink = new AjaxLink("agregatesReportLink") {
        public void onClick(AjaxRequestTarget target) {

            agregatesReportModal
                    .setContent(new AggregatesReportPanel("content", agregatesReportModal, itemSearch));
            agregatesReportModal.setTitle("");
            agregatesReportModal.show(target);
        }
    };
    agregatesContainer.add(agregatesReportLink);
    add(agregatesContainer.setVisible(showAgregates));
    //       }
    //       else{
    //          add(new EmptyPanel("agregatesReportLink"));
    //       }

}

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

License:Open Source License

private void addSaveSearch() {
    // --- Search Container ------------------------------------
    saveSearchContainer = new WebMarkupContainer("saveSearchContainer");
    saveSearchContainer.setOutputMarkupId(true);
    add(saveSearchContainer);/*  w ww  .  j  a  v a 2 s . c o  m*/

    // ---- Save Link -----------------------------------------

    AjaxLink saveSearchLink = new AjaxLink("saveSearchLink") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            //Form panel is not exists
            if (saveSearchPanelContainer != null) {
                //Remove container
                saveSearchContainer.remove(saveSearchPanelContainer);
                saveSearchPanelContainer = null;

                //Add form panel
                saveSearchFormPanel = new SaveSearchFormPanel("saveSearchFormPanel");
                saveSearchFormPanel.setCancelTargetComponent(saveSearchContainer);
                saveSearchContainer.add(saveSearchFormPanel);
            } //if
            else { //from panel exists
                   //Remove form panel
                saveSearchContainer.remove(saveSearchFormPanel);
                saveSearchFormPanel = null;

                //Add container
                saveSearchPanelContainer = new WebMarkupContainer("saveSearchFormPanel");
                saveSearchContainer.add(saveSearchPanelContainer);
            } //else

            target.addComponent(saveSearchContainer.setVisible(!getPrincipal().isAnonymous()));
        }//onClick
    };
    saveSearchContainer.add(saveSearchLink);

    // ---- Save Search Panel ---------------------------------
    saveSearchPanelContainer = new WebMarkupContainer("saveSearchFormPanel");
    //add(saveSearchPanelContainer);
    saveSearchContainer.add(saveSearchPanelContainer);
}

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

License:Open Source License

public ItemRelatePanel(String id, boolean isItemViewPage) {
    super(id);//w w  w.  j  a v  a2s .  co m
    ItemSearch itemSearch = getCurrentItemSearch();
    refId = itemSearch == null ? null : itemSearch.getRelatingItemRefId();
    if (refId != null) {
        final YuiDialog dialog = new YuiDialog("itemWindow");
        add(dialog);
        AjaxLink link = new AjaxLink("link") {
            public void onClick(AjaxRequestTarget target) {
                Item item = getCalipso().loadItemByRefId(refId);
                dialog.show(target, refId,
                        new ItemView(YuiDialog.CONTENT_ID, getCalipso().getItemRenderingTemplateForUser(
                                getPrincipal(), item.getStatus(), item.getSpace().getId()), item));
            }
        };
        link.add(new Label("refId", refId));
        if (isItemViewPage) {
            add(new WebMarkupContainer("link").setVisible(false));
            add(new WebMarkupContainer("message").setVisible(false));
            add(new RelateForm("form").add(link));
        } else {
            add(new Label("message", localize("item_list.searchingForRelated")));
            add(link);
            add(new WebMarkupContainer("form").setVisible(false));
        }
        add(new Link("cancel") {
            public void onClick() {
                Item item = getCalipso().loadItemByRefId(refId);
                setCurrentItemSearch(null);
                setResponsePage(ItemViewPage.class, new PageParameters("0=" + item.getUniqueRefId()));
            }
        });
    } else {
        setVisible(false);
    }
}

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

License:Open Source License

public ItemRelateRemovePage(long itemId, final ItemItem itemItem) {
    this.itemId = itemId;
    this.itemItem = itemItem;
    add(new ConfirmForm("form"));
    final String relatingRefId = itemItem.getItem().getUniqueRefId();
    final String relatedRefId = itemItem.getRelatedItem().getUniqueRefId();
    final YuiDialog relatingDialog = new YuiDialog("relatingDialog");
    final YuiDialog relatedDialog = new YuiDialog("relatedDialog");
    add(relatingDialog);//from  ww  w .  j  av  a 2 s  .  co m
    add(relatedDialog);
    AjaxLink relating = new AjaxLink("relating") {
        public void onClick(AjaxRequestTarget target) {
            Item relating = getCalipso().loadItem(itemItem.getItem().getId());
            relatingDialog.show(target, relatingRefId,
                    new ItemView(YuiDialog.CONTENT_ID, getCalipso().getItemRenderingTemplateForUser(
                            getPrincipal(), relating.getStatus(), relating.getSpace().getId()), relating));
        }
    };
    relating.add(new Label("refId", relatingRefId));
    add(relating);

    // TODO refactor, duplicate code in ItemView
    String message = null;
    if (itemItem.getType() == DUPLICATE_OF) {
        message = localize("item_view.duplicateOf");
    } else if (itemItem.getType() == DEPENDS_ON) {
        message = localize("item_view.dependsOn");
    } else if (itemItem.getType() == RELATED) {
        message = localize("item_view.relatedTo");
    }
    add(new Label("message", message));

    AjaxLink related = new AjaxLink("related") {
        public void onClick(AjaxRequestTarget target) {
            Item related = getCalipso().loadItem(itemItem.getRelatedItem().getId());
            relatedDialog.show(target, relatedRefId,
                    new ItemView(YuiDialog.CONTENT_ID, getCalipso().getItemRenderingTemplateForUser(
                            getPrincipal(), related.getStatus(), related.getSpace().getId()), related));
        }
    };
    related.add(new Label("refId", itemItem.getRelatedItem().getUniqueRefId()));
    add(related);

}