Example usage for org.apache.wicket.markup.html.form SubmitLink add

List of usage examples for org.apache.wicket.markup.html.form SubmitLink add

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.form SubmitLink add.

Prototype

public MarkupContainer add(final Component... children) 

Source Link

Document

Adds the child component(s) to this container.

Usage

From source file:com.francetelecom.clara.cloud.presentation.applications.ApplicationsTablePanel.java

License:Apache License

private void createSearchCriteriaForm() {
    searchCriteriaForm = new Form<Void>("searchCriteriaForm");
    searchCriteriaForm/*from   w  w w. j ava2s.  c om*/
            .add(new CacheActivatedImage("imageHelp.searchField", new ResourceModel("image.help").getObject()));
    addOrReplace(searchCriteriaForm);
    searchCriteriaForm
            .add(new TextField<String>("searchCriteria", new PropertyModel<String>(this, "searchCriteria")));
    SubmitLink searchLink = new SubmitLink("searchLink");
    CacheActivatedImage imageSearch = new CacheActivatedImage("imageSearch",
            new ResourceModel("image.help").getObject());
    searchLink.add(imageSearch);
    searchCriteriaForm.add(searchLink);
}

From source file:com.francetelecom.clara.cloud.presentation.environments.EnvironmentsTablePanel.java

License:Apache License

private void createSearchCriteriaForm() {
    searchCriteriaForm = new Form<Void>("searchCriteriaForm");
    searchCriteriaForm.add(new CacheActivatedImage("imageHelp.searchField", getString("image.help")));
    addOrReplace(searchCriteriaForm);/*from  ww w .j a  v  a  2 s .c  om*/
    searchCriteriaForm
            .add(new TextField<String>("searchCriteria", new PropertyModel<String>(this, "searchCriteria")));
    SubmitLink searchLink = new SubmitLink("searchLink");
    CacheActivatedImage imageSearch = new CacheActivatedImage("imageSearch", getString("image.search"));
    searchLink.add(imageSearch);
    searchCriteriaForm.add(searchLink);
}

From source file:com.tysanclan.site.projectewok.pages.member.justice.TruthSayerEditUserPage.java

License:Open Source License

public TruthSayerEditUserPage(User user) {
    super("Edit user");

    User givenUser = null;// w w  w .j a  v  a  2s  . co  m
    if (user != null) {
        givenUser = userDao.load(user.getId());
    }

    Form<Void> form = new Form<Void>("userSearchForm") {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit() {
            UserFilter filter = new UserFilter();
            filter.setUsername(get("username").getDefaultModelObjectAsString());
            User foundUser = userDao.getUniqueByFilter(filter);
            if (foundUser == null) {
                warn("Could not find user");
                return;
            }
            setResponsePage(new TruthSayerEditUserPage(foundUser));
        }
    };
    form.add(new TextField<String>("username",
            new Model<String>(givenUser != null ? givenUser.getUsername() : "")));
    SubmitLink submit = new SubmitLink("submit", form);
    submit.add(new ContextImage("search", "images/icons/magnifier.png"));
    form.add(submit);

    ConfirmationLink<User> removeAvatarLink = new ConfirmationLink<User>("removeAvatar",
            new Model<User>(givenUser), "Are you sure you want to delete this users avatar?") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            User selectedUser = getModelObject();
            if (selectedUser != null) {
                userService.setUserAvatar(selectedUser.getId(), null);
                notificationService.notifyUser(selectedUser, "Your avatar has been removed by a Truthsayer");
                setResponsePage(new TruthSayerEditUserPage(selectedUser));
            }
        }

    };

    ConfirmationLink<User> removeSignatureLink = new ConfirmationLink<User>("removeSignature",
            new Model<User>(givenUser), "Are you sure you want to delete this users signature?") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            User selectedUser = getModelObject();
            if (selectedUser != null) {
                userService.setUserSignature(selectedUser.getId(), "");
                notificationService.notifyUser(selectedUser, "Your signature has been removed by a Truthsayer");
                setResponsePage(new TruthSayerEditUserPage(selectedUser));
            }
        }

    };

    ConfirmationLink<User> removeCustomTitleLink = new ConfirmationLink<User>("removeCustomTitleLink",
            new Model<User>(givenUser), "Are you sure you want to delete this users custom title?") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            User selectedUser = getModelObject();
            if (selectedUser != null) {
                userService.setUserCustomTitle(selectedUser.getId(), "");
                notificationService.notifyUser(selectedUser,
                        "Your custom title has been removed by a Truthsayer");
                setResponsePage(new TruthSayerEditUserPage(selectedUser));
            }
        }

    };

    removeAvatarLink.setEnabled(
            givenUser != null && givenUser.getImageURL() != null && !givenUser.getImageURL().isEmpty());
    removeSignatureLink.setEnabled(
            givenUser != null && givenUser.getSignature() != null && !givenUser.getSignature().isEmpty());
    removeCustomTitleLink.setEnabled(
            givenUser != null && givenUser.getCustomTitle() != null && !givenUser.getCustomTitle().isEmpty());

    removeAvatarLink.add(new ContextImage("delete", "images/icons/delete.png"));
    removeSignatureLink.add(new ContextImage("delete", "images/icons/delete.png"));
    removeCustomTitleLink.add(new ContextImage("delete", "images/icons/delete.png"));

    add(new Label("username", new Model<String>(givenUser != null ? givenUser.getUsername() : "")));
    add(removeAvatarLink);
    add(removeSignatureLink);
    add(removeCustomTitleLink);
    add(form);
}

From source file:drat.proteus.DratStartForm.java

License:Apache License

public DratStartForm(String name, FileUploadField fileUploader, TextField<String> path) {
    super(name);//from   www  .ja  va2s  .co m
    fileUploadField = fileUploader;
    pathField = path;
    String[] cmdArray = { "Crawl", "Index", "Map", "Reduce", "Go" };
    List<String> commands = (List<String>) Arrays.asList(cmdArray);
    cmdSelect = new ListView<String>("cmd", commands) {
        @Override
        protected void populateItem(final ListItem<String> item) {
            final String cmdItemLabel = item.getModelObject();
            SubmitLink link = new SubmitLink("cmd_link") {
                @Override
                public void onSubmit() {
                    theCommand = cmdItemLabel;
                }
            };

            link.add(new Label("cmd_item_label", cmdItemLabel));
            item.add(link);

        }
    };
    this.add(fileUploadField);
    this.add(path);
    this.add(cmdSelect);
}

From source file:net.form105.web.base.component.command.CommandPanel.java

License:Apache License

@SuppressWarnings("unchecked")
private ListView createListView() {
    ListView lView = new ListView("commandLabels", linkList) {
        private static final long serialVersionUID = 1L;

        @Override/*from   ww w .  j  a va 2  s  .co m*/
        protected void populateItem(ListItem item) {
            IPageAction action = (IPageAction) item.getModelObject();
            SubmitLink submitLink;
            if (action instanceof AbstractFormAction) {
                AbstractFormAction<T> formAction = (AbstractFormAction<T>) action;
                submitLink = new SubmitLink("commandLink", formAction.getForm()) {

                    private static final long serialVersionUID = 1L;

                    public void onSubmit() {
                        setResponsePage(this.getPage());
                    }
                };

                Label label = new Label("commandLabel", formAction.getName());
                submitLink.add(label);
                item.add(submitLink);

            } else if (action instanceof IAjaxLinkToPanelAction) {
                IAjaxLinkToPanelAction ajaxLinkAction = (IAjaxLinkToPanelAction) action;
                AjaxLink ajaxLink = new AjaxLink("commandLink") {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        Page page = getPage();
                        ((BasePage) page).ajaxRequestReceived(target, null, EventType.ADD_EVENT);

                    }

                };
                Label label = new Label("commandLabel", ajaxLinkAction.getName());
                ajaxLink.add(label);
                item.add(ajaxLink);

            } else if (action instanceof IAjaxLinkToModalWindowAction) {
                IAjaxLinkToModalWindowAction ajaxModalAction = (IAjaxLinkToModalWindowAction) action;
                AjaxLink ajaxLink = new AjaxLink("commandLink") {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        Page page = getPage();
                        ((BasePage) page).ajaxRequestReceived(target, null, EventType.ADD_MODAL);
                    }
                };
                Label label = new Label("commandLabel", ajaxModalAction.getName());
                ajaxLink.add(label);
                item.add(ajaxLink);
            }
        }
    };
    return lView;
}

From source file:nl.knaw.dans.common.wicket.components.editablepanel.EditablePanel.java

License:Apache License

@SuppressWarnings("serial")
private SubmitLink createModeLink() {
    final SubmitLink modeLink = new SubmitLink("modeLink") {
        @Override/*from w  w w  . j av  a2  s  .  co m*/
        public void onSubmit() {
            inEditMode = !inEditMode;
            setContentPanel();
        }

        @Override
        public boolean isVisible() {
            return context.isEditModeAllowed();
        }
    };

    modeLink.add(new Label("modeLinkLabel", new AbstractReadOnlyModel<String>() {
        @Override
        public String getObject() {
            final ComponentStringResourceLoader resources = new ComponentStringResourceLoader();
            return resources.loadStringResource(EditablePanel.this,
                    inEditMode ? "displayLinkLabel" : "editLinkLabel");
        }
    }));

    return modeLink;
}

From source file:nl.knaw.dans.dccd.web.authn.UserStatusChangeActionSelectionPanel.java

License:Apache License

public void init() {
    // Add selection and enable/disable the 'action buttons' using actionSelection

    // Acivate//w ww .j a va  2s  . c  o m
    SubmitLink userActivate = new SubmitLink("userActivate") {
        private static final long serialVersionUID = -661621354590046086L;

        public void onSubmit() {
            logger.debug("userActivate.onSubmit executed");
            getSelection().setSelectedAction(Action.ACTIVATE);
        }
    };
    add(userActivate);
    userActivate.setVisible(getSelection().isAlowedAction(Action.ACTIVATE));
    // confirmation, only for ACTIVATE
    if (getSelection().isAlowedAction(Action.ACTIVATE)) {
        if (getSelection().hasConfirmation(Action.ACTIVATE)) {
            userActivate.add(new LinkConfirmationBehavior(getSelection().getConfirmation(Action.ACTIVATE)));
        }
    }

    // Delete
    SubmitLink userDelete = new SubmitLink("userDelete") {
        private static final long serialVersionUID = -976047485479669445L;

        public void onSubmit() {
            logger.debug("userDelete.onSubmit executed");
            getSelection().setSelectedAction(Action.DELETE);
        }
    };
    add(userDelete);
    userDelete.setVisible(getSelection().isAlowedAction(Action.DELETE));

    // Restore
    SubmitLink userRestore = new SubmitLink("userRestore") {
        private static final long serialVersionUID = 317247670008469017L;

        public void onSubmit() {
            logger.debug("userRestore.onSubmit executed");
            getSelection().setSelectedAction(Action.RESTORE);
        }
    };
    add(userRestore);
    userRestore.setVisible(getSelection().isAlowedAction(Action.RESTORE));
}

From source file:org.cast.cwm.admin.EditUserPanel.java

License:Open Source License

/**
 * Returns a link that will be used to submit the form.
 * This can be overridden to use a button or other component.
 * // ww  w .j  a v  a2s.  c o  m
 * TODO: This "operation" thing is hidden and can cause confusion when subclasses
 * override this method.  Should just expect a single Component, which may be a panel/fragment.
 * 
 * @param id The wicket ID for the component
 * @return a Component, or null if there should be none.
 */
protected Component getSubmitComponent(String id) {
    SubmitLink link = new SubmitLink(id);
    link.add(new Label("operation", new AbstractReadOnlyModel<String>() {
        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return userForm.getModelObject().isTransient() ? "Create User" : "Update User";
        }
    }));
    return link;
}

From source file:org.geoserver.web.data.store.NewDataPage.java

License:Open Source License

/**
 * Creates the page components to present the list of available vector and raster data source
 * types/*from   w  w  w .j  a  v  a2 s .c  o  m*/
 * 
 * @param workspaceId
 *            the id of the workspace to attach the new resource store to.
 */
@SuppressWarnings("serial")
public NewDataPage() {

    final boolean thereAreWorkspaces = !getCatalog().getWorkspaces().isEmpty();

    if (!thereAreWorkspaces) {
        super.error((String) new ResourceModel("NewDataPage.noWorkspacesErrorMessage").getObject());
    }

    final Form storeForm = new Form("storeForm");
    add(storeForm);

    final ArrayList<String> sortedDsNames = new ArrayList<String>(getAvailableDataStores().keySet());
    Collections.sort(sortedDsNames);

    final CatalogIconFactory icons = CatalogIconFactory.get();
    final ListView dataStoreLinks = new ListView("vectorResources", sortedDsNames) {
        @Override
        protected void populateItem(ListItem item) {
            final String dataStoreFactoryName = item.getDefaultModelObjectAsString();
            final DataAccessFactory factory = getAvailableDataStores().get(dataStoreFactoryName);
            final String description = factory.getDescription();
            SubmitLink link;
            link = new SubmitLink("resourcelink") {
                @Override
                public void onSubmit() {
                    setResponsePage(new DataAccessNewPage(dataStoreFactoryName));
                }
            };
            link.setEnabled(thereAreWorkspaces);
            link.add(new Label("resourcelabel", dataStoreFactoryName));
            item.add(link);
            item.add(new Label("resourceDescription", description));
            Image icon = new Image("storeIcon", icons.getStoreIcon(factory.getClass()));
            // TODO: icons could provide a description too to be used in alt=...
            icon.add(new AttributeModifier("alt", true, new Model("")));
            item.add(icon);
        }
    };

    final List<String> sortedCoverageNames = new ArrayList<String>();
    sortedCoverageNames.addAll(getAvailableCoverageStores().keySet());
    Collections.sort(sortedCoverageNames);

    final ListView coverageLinks = new ListView("rasterResources", sortedCoverageNames) {
        @Override
        protected void populateItem(ListItem item) {
            final String coverageFactoryName = item.getDefaultModelObjectAsString();
            final Map<String, Format> coverages = getAvailableCoverageStores();
            Format format = coverages.get(coverageFactoryName);
            final String description = format.getDescription();
            SubmitLink link;
            link = new SubmitLink("resourcelink") {
                @Override
                public void onSubmit() {
                    setResponsePage(new CoverageStoreNewPage(coverageFactoryName));
                }
            };
            link.setEnabled(thereAreWorkspaces);
            link.add(new Label("resourcelabel", coverageFactoryName));
            item.add(link);
            item.add(new Label("resourceDescription", description));
            Image icon = new Image("storeIcon", icons.getStoreIcon(format.getClass()));
            // TODO: icons could provide a description too to be used in alt=...
            icon.add(new AttributeModifier("alt", true, new Model("")));
            item.add(icon);
        }
    };

    final List<OtherStoreDescription> otherStores = getOtherStores();

    final ListView otherStoresLinks = new ListView("otherStores", otherStores) {
        @Override
        protected void populateItem(ListItem item) {
            final OtherStoreDescription store = (OtherStoreDescription) item.getModelObject();
            SubmitLink link;
            link = new SubmitLink("resourcelink") {
                @Override
                public void onSubmit() {
                    setResponsePage(store.configurationPage);
                }
            };
            link.setEnabled(thereAreWorkspaces);
            link.add(
                    new Label("resourcelabel", new ParamResourceModel("other." + store.key, NewDataPage.this)));
            item.add(link);
            item.add(new Label("resourceDescription",
                    new ParamResourceModel("other." + store.key + ".description", NewDataPage.this)));
            Image icon = new Image("storeIcon", store.icon);
            // TODO: icons could provide a description too to be used in alt=...
            icon.add(new AttributeModifier("alt", true, new Model("")));
            item.add(icon);
        }
    };

    storeForm.add(dataStoreLinks);
    storeForm.add(coverageLinks);
    storeForm.add(otherStoresLinks);
}

From source file:org.projectforge.plugins.skillmatrix.SkillSelectPanel.java

License:Open Source License

/**
 * @see org.projectforge.web.wicket.AbstractSelectPanel#onBeforeRender()
 *///w  w w  .jav  a 2 s.c  o  m
@SuppressWarnings("serial")
@Override
protected void onBeforeRender() {
    super.onBeforeRender();
    final SkillDO skill = getModelObject();
    final Integer skillId = skill != null ? skill.getId() : null;
    if (currentSkillId == skillId) {
        return;
    }
    currentSkillId = skillId;
    if (showPath == true && skill != null) {
        ancestorRepeater.removeAll();
        final SkillNode skillNode = getSkillTree().getSkillNodeById(skill.getId());
        final List<Integer> ancestorIds = skillNode.getAncestorIds();
        final ListIterator<Integer> it = ancestorIds.listIterator(ancestorIds.size());
        while (it.hasPrevious() == true) {
            final Integer ancestorId = it.previous();
            final SkillDO ancestorSkill = getSkillTree().getSkillById(ancestorId);
            if (ancestorSkill.getParent() == null) {
                // Don't show root node:
                continue;
            }
            final WebMarkupContainer cont = new WebMarkupContainer(ancestorRepeater.newChildId());
            ancestorRepeater.add(cont);
            final SubmitLink selectSkillLink = new SubmitLink("ancestorSkillLink") {
                @Override
                public void onSubmit() {
                    caller.select(selectProperty, ancestorSkill.getId());
                }
            };
            selectSkillLink.setDefaultFormProcessing(false);
            cont.add(selectSkillLink);
            WicketUtils.addTooltip(selectSkillLink, getString(I18N_KEY_SELECT_ANCESTOR_SKILL_TOOLTIP));
            selectSkillLink.add(new Label("name", ancestorSkill.getTitle()));
        }
        ancestorRepeater.setVisible(true);
    } else {
        ancestorRepeater.setVisible(false);
    }
}