List of usage examples for org.apache.wicket.ajax.markup.html AjaxLink AjaxLink
public AjaxLink(final String id)
From source file:gr.abiss.calipso.wicket.SearchOnAnotherSpacePanel.java
License:Open Source License
private void addComponents() { final List<Space> userSpaces = new ArrayList<Space>(getPrincipal().getSpaces()); if (getCurrentSpace() != null) { //Use, for all space search Space emptySpace = new Space(); emptySpace.setId(0);/*from www. j a va 2 s. c om*/ emptySpace.setName(localize("item_search_form.allSpaces")); emptySpace.setPrefixCode(""); userSpaces.add(0, emptySpace); userSpaces.remove(getCurrentSpace()); } // -- Spaces Drop Down List ------------------------------------------- final DropDownChoice allSpaces = new DropDownChoice("allSpaces", new Model(), userSpaces, new IChoiceRenderer() { public String getIdValue(Object object, int index) { return String.valueOf(((Space) object).getId()); } public Object getDisplayValue(Object object) { return localize(((Space) object).getNameTranslationResourceKey()); } }); allSpaces.setNullValid(false); allSpaces.setOutputMarkupId(true); allSpaces.add(new AjaxFormComponentUpdatingBehavior("onchange") { protected void onUpdate(AjaxRequestTarget target) { //Do nothing. Needed for get its value via ajax. }//onUpdate }); add(allSpaces); // -- Search Button ------------------------------------------- final AjaxLink go = new AjaxLink("go") { @Override public void onClick(AjaxRequestTarget target) { target.addComponent(allSpaces); if (allSpaces.getValue() != null && !allSpaces.getValue().equals("") && !allSpaces.getValue().equals("-1")) { if (allSpaces.getValue().equals("0")) {//All Spaces ((CalipsoSession) getSession()).setCurrentSpace(null); setResponsePage(ItemSearchFormPage.class); } //if else { Space selectedSpace = getCalipso().loadSpace(Long.parseLong(allSpaces.getValue())); for (Space space : userSpaces) { if (space.equals(selectedSpace)) { setCurrentSpace(space); setResponsePage(ItemSearchFormPage.class); } //if } //for } //else } } }; go.setOutputMarkupId(true); add(go); }
From source file:gr.abiss.calipso.wicket.SearchUserPanel.java
License:Open Source License
private void addComponents() { setOutputMarkupId(true);//from www . jav a 2s . c om // Toggle View/Hide Search User possibility AjaxLink findUser = new AjaxLink("findUser") { @Override public void onClick(AjaxRequestTarget target) { if (searchIsVisible) { SearchUserPanel.this.remove(findUserFragment); findUserPlaceHolder = new WebMarkupContainer("findUserPlaceHolder"); findUserPlaceHolder.setOutputMarkupId(true); SearchUserPanel.this.add(findUserPlaceHolder); } // if else { SearchUserPanel.this.remove(findUserPlaceHolder); findUserFragment = new Fragment("findUserPlaceHolder", "findUserFragment", SearchUserPanel.this); findUserFragment.add(new AjaxLink("close") { @Override public void onClick(AjaxRequestTarget target) { SearchUserPanel.this.remove(SearchUserPanel.this.findUserFragment); findUserPlaceHolder = new WebMarkupContainer("findUserPlaceHolder"); findUserPlaceHolder.setOutputMarkupId(true); SearchUserPanel.this.add(SearchUserPanel.this.findUserPlaceHolder); searchIsVisible = !searchIsVisible; target.addComponent(SearchUserPanel.this); } }); findUserFragment.add(renderSearchCriteria()); findUserFragment.setOutputMarkupId(true); SearchUserPanel.this.add(findUserFragment); } // else SearchUserPanel.this.findUserPlaceHolder.setOutputMarkupId(true); SearchUserPanel.this.searchIsVisible = !SearchUserPanel.this.searchIsVisible; target.addComponent(SearchUserPanel.this); } }; add(findUser); this.findUserPlaceHolder = new WebMarkupContainer("findUserPlaceHolder"); this.findUserPlaceHolder.setOutputMarkupId(true); add(this.findUserPlaceHolder); }
From source file:gr.abiss.calipso.wicket.SearchUserPanel.java
License:Open Source License
private WebMarkupContainer renderSearchCriteria() { final WebMarkupContainer searchFormContainer = new WebMarkupContainer("searchFormContainer"); searchFormContainer.setOutputMarkupId(true); List<String> searchOnOptions = Arrays .asList(new String[] { "loginName", "name", "lastname", "email", "address", "phone" }); searchOnChoice = new DropDownChoice("searchOn", new PropertyModel(SearchUserPanel.this, "searchOn"), searchOnOptions, new IChoiceRenderer() { public Object getDisplayValue(Object o) { String s = (String) o; return localize("user_list." + s); }//from w w w . j a va2 s .c o m public String getIdValue(Object o, int i) { return o.toString(); } }); searchOnChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { searchOn = searchOnChoice.getDefaultModelObjectAsString(); target.addComponent(searchFormContainer); } }); searchFormContainer.add(searchOnChoice); searchTextField = new TextField("searchText", new PropertyModel(SearchUserPanel.this, "searchText")); searchTextField.setOutputMarkupId(true); searchTextField.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { searchText = searchTextField.getDefaultModelObjectAsString(); target.addComponent(searchFormContainer); } }); searchFormContainer.add(searchTextField); searchFormContainer.add(new Behavior() { public void renderHead(IHeaderResponse response) { response.renderOnLoadJavaScript( "document.getElementById('" + searchTextField.getMarkupId() + "').focus()"); } }); AjaxLink submit = new AjaxLink("submit") { @Override public void onClick(AjaxRequestTarget target) { if (usersDataViewContainer != null) { searchFormContainer.remove(usersDataViewContainer); } searchFormContainer.add(renderUserDataView()); target.addComponent(searchFormContainer); } }; searchFormContainer.add(submit); searchFormContainer.add(renderUsersDataViewContainer(false)); return searchFormContainer; }
From source file:gr.abiss.calipso.wicket.SpaceFieldListPanel.java
License:Open Source License
public SpaceFieldListPanel(String id, IBreadCrumbModel breadCrumbModel, final Space space, String selectedFieldName) { super(id, breadCrumbModel); setupVisuals(space);//from w w w . j a v a 2 s . c o m // FIELD GROUPS List<IGridColumn> cols = (List) Arrays.asList(new CheckBoxColumn("selected"), new PropertyColumn(new Model("Id"), "id"), new PropertyColumn(new Model("Name"), "name"), new PropertyColumn(new Model("Priority"), "priority")); final ListDataProvider listDataProvider = new ListDataProvider(space.getMetadata().getFieldGroups()); final WebMarkupContainer gridContainer = new WebMarkupContainer("gridContainer"); gridContainer.setOutputMarkupId(true); final DataGrid grid = new DefaultDataGrid("fieldGroupGrid", new DataProviderAdapter(listDataProvider), cols); grid.setSelectToEdit(false); grid.setClickRowToSelect(true); grid.setAllowSelectMultiple(false); gridContainer.add(grid); add(gridContainer); // add "new" link final ModalWindow fieldGroupModal = new ModalWindow("fieldGroupModal"); gridContainer.add(fieldGroupModal); gridContainer.add(grid); add(gridContainer); add(new AjaxLink("newFieldGroupLink") { public void onClick(AjaxRequestTarget target) { // TODO: add row to grid? final FieldGroup tpl; if (CollectionUtils.isNotEmpty(grid.getSelectedItems())) { tpl = (FieldGroup) ((IModel) grid.getSelectedItems().iterator().next()).getObject(); } else { tpl = new FieldGroup("", ""); } fieldGroupModal.setContent(new EditFieldGroupPanel("content", fieldGroupModal, tpl) { @Override protected void persist(AjaxRequestTarget target, Form form) { if (!space.getMetadata().getFieldGroups().contains(tpl)) { space.getMetadata().getFieldGroups().add(tpl); //logger.info("added new fieldgroup to space"); } SortedSet<FieldGroup> fieldGroups = new TreeSet<FieldGroup>(); fieldGroups.addAll(space.getMetadata().getFieldGroups()); space.getMetadata().getFieldGroups().clear(); space.getMetadata().getFieldGroups().addAll(fieldGroups); //update grid if (target != null) { target.addComponent(gridContainer); } } }); fieldGroupModal.setTitle(this.getLocalizer().getString("fieldGroups", this)); fieldGroupModal.show(target); } }); // FIELDS SpaceFieldsForm form = new SpaceFieldsForm("form", space, selectedFieldName); add(form); }
From source file:gr.interamerican.wicket.factories.LinkFactory.java
License:Open Source License
/** * Creates an AjaxLink that togles on/of the visibility of a component. * //w w w . ja v a2 s. co m * The Component must have <code>outputMarkUpPlaceholderId = true</code>. * * @param componentName * Name of the panel who's visibility is toggled on/off. * @param <T> * Type of link model object. * * @param container - O container that contains the component and the link. * * @return Returns the link. */ public static <T> AjaxLink<T> createTogleVisibleLink(final String componentName, final MarkupContainer container) { AjaxLink<T> refreshLink = new AjaxLink<T>(componentName + "Link") { //$NON-NLS-1$ /** * serialize. */ private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { Component component = container.get(componentName); boolean newVisibility = !component.isVisible(); component.setVisible(newVisibility); target.add(component); } }; return refreshLink; }
From source file:guru.mmp.application.web.template.components.FormDialog.java
License:Apache License
/** * Constructs a new <code>FormDialog</code>. * * @param id the non-null id of this component * @param title the title for the form dialog * @param submitText the text to display on the "submit" button * @param cancelText the text to display on the "cancel" button *//*from w w w .j a v a2 s . c o m*/ public FormDialog(String id, String title, String submitText, String cancelText) { super(id); this.title = title; this.submitText = submitText; this.cancelText = cancelText; Label titleLabel = new Label("title", new PropertyModel<String>(this, "title")); titleLabel.setRenderBodyOnly(true); add(titleLabel); alerts = new Alerts("alerts", id); add(alerts); form = new Form<>("form"); add(form); AjaxButton submitButton = new AjaxButton("submitButton", form) { @Override protected void onError(AjaxRequestTarget target, Form<?> form) { super.onError(target, form); if (target != null) { // Visit each form component and if it is visible re-render it. // NOTE: We have to re-render every component to remove stale validation error messages. form.visitFormComponents((formComponent, iVisit) -> { if ((formComponent.getParent() != null) && formComponent.getParent().isVisible() && formComponent.isVisible()) { target.add(formComponent); } }); } FormDialog.this.onError(target, FormDialog.this.getForm()); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { if (target != null) { resetFeedbackMessages(target); } if (FormDialog.this.onSubmit(target, FormDialog.this.getForm())) { hide(target); } else { target.add(getAlerts()); } } }; submitButton.setDefaultFormProcessing(true); add(submitButton); Label submitTextLabel = new Label("submitText", new PropertyModel<String>(this, "submitText")); submitTextLabel.setRenderBodyOnly(true); submitButton.add(submitTextLabel); AjaxLink cancelLink = new AjaxLink("cancelLink") { @Override public void onClick(AjaxRequestTarget target) { FormDialog.this.onCancel(target, getForm()); hide(target); } }; add(cancelLink); Label cancelTextLabel = new Label("cancelText", new PropertyModel<String>(this, "cancelText")); cancelTextLabel.setRenderBodyOnly(true); cancelLink.add(cancelTextLabel); }
From source file:guru.mmp.application.web.template.pages.CodeAdministrationPage.java
License:Apache License
/** * Constructs a new <code>CodeAdministrationPage</code>. * * @param previousPage the previous page * @param codeCategoryId the Universally Unique Identifier (UUID) used to uniquely identify the * code category the codes are associated with * @param codeCategoryName the name of the code category *//*from w w w . ja v a 2 s .com*/ CodeAdministrationPage(PageReference previousPage, UUID codeCategoryId, String codeCategoryName) { super("Codes", codeCategoryName); try { /* * The table container, which allows the table and its associated navigator to be updated * using AJAX. */ WebMarkupContainer tableContainer = new WebMarkupContainer("tableContainer"); tableContainer.setOutputMarkupId(true); add(tableContainer); // The dialog used to confirm the removal of a code RemoveDialog removeDialog = new RemoveDialog(tableContainer); add(removeDialog); // The "addLink" link Link<Void> addLink = new Link<Void>("addLink") { private static final long serialVersionUID = 1000000; @Override public void onClick() { AddCodePage page = new AddCodePage(getPageReference(), codeCategoryId); setResponsePage(page); } }; tableContainer.add(addLink); // The "backLink" link Link<Void> backLink = new Link<Void>("backLink") { private static final long serialVersionUID = 1000000; @Override public void onClick() { setResponsePage(previousPage.getPage()); } }; tableContainer.add(backLink); // The code data view CodeDataProvider dataProvider = new CodeDataProvider(codeCategoryId); DataView<Code> dataView = new DataView<Code>("code", dataProvider) { private static final long serialVersionUID = 1000000; @Override protected void populateItem(Item<Code> item) { Code code = item.getModelObject(); String name = StringUtil.truncate(code.getName(), 25); String value = StringUtil.truncate(code.getValue(), 30); item.add(new Label("name", Model.of(name))); item.add(new Label("value", Model.of(value))); // The "updateLink" link Link<Void> updateLink = new Link<Void>("updateLink") { private static final long serialVersionUID = 1000000; @Override public void onClick() { UpdateCodePage page = new UpdateCodePage(getPageReference(), item.getModel()); setResponsePage(page); } }; item.add(updateLink); // The "removeLink" link AjaxLink<Void> removeLink = new AjaxLink<Void>("removeLink") { private static final long serialVersionUID = 1000000; @Override public void onClick(AjaxRequestTarget target) { removeDialog.show(target, item.getModel()); } }; item.add(removeLink); } }; dataView.setItemsPerPage(10); dataView.setItemReuseStrategy(ReuseIfModelsEqualStrategy.getInstance()); tableContainer.add(dataView); tableContainer.add(new PagingNavigator("navigator", dataView)); } catch (Throwable e) { throw new WebApplicationException("Failed to initialise the CodeAdministrationPage", e); } }
From source file:guru.mmp.application.web.template.pages.CodeCategoryAdministrationPage.java
License:Apache License
/** * Constructs a new <code>CodeCategoryAdministrationPage</code>. *//*from ww w .j av a 2s.c o m*/ public CodeCategoryAdministrationPage() { super("Code Categories"); try { /* * The table container, which allows the table and its associated navigator to be updated * using AJAX. */ WebMarkupContainer tableContainer = new WebMarkupContainer("tableContainer"); tableContainer.setOutputMarkupId(true); add(tableContainer); // The dialog used to confirm the removal of a code category RemoveDialog removeDialog = new RemoveDialog(tableContainer); add(removeDialog); // The "addLink" used to add a new code category Link<Void> addLink = new Link<Void>("addLink") { private static final long serialVersionUID = 1000000; @Override public void onClick() { setResponsePage(new AddCodeCategoryPage(getPageReference())); } }; tableContainer.add(addLink); // The code category data view CodeCategoryDataProvider dataProvider = new CodeCategoryDataProvider(false); DataView<CodeCategory> dataView = new DataView<CodeCategory>("codeCategory", dataProvider) { private static final long serialVersionUID = 1000000; @Override protected void populateItem(Item<CodeCategory> item) { item.add(new Label("name", new PropertyModel<String>(item.getModel(), "name"))); item.add(new Label("categoryType", new PropertyModel<String>(item.getModel(), "categoryType.name"))); // The "updateLink" link Link<Void> updateLink = new Link<Void>("updateLink") { private static final long serialVersionUID = 1000000; @Override public void onClick() { UpdateCodeCategoryPage page = new UpdateCodeCategoryPage(getPageReference(), item.getModel()); setResponsePage(page); } }; item.add(updateLink); // The "removeLink" link AjaxLink<Void> removeLink = new AjaxLink<Void>("removeLink") { private static final long serialVersionUID = 1000000; @Override public void onClick(AjaxRequestTarget target) { removeDialog.show(target, item.getModel()); } }; item.add(removeLink); // The "codeAdministrationLink" link Link<Void> codeAdministrationLink = new Link<Void>("codeAdministrationLink") { private static final long serialVersionUID = 1000000; @Override public boolean isVisible() { return item.getModelObject().getCategoryType() == CodeCategoryType.LOCAL_STANDARD; } @Override public void onClick() { CodeCategory codeCategory = item.getModelObject(); UUID codeCategoryId = codeCategory.getId(); String codeCategoryName = codeCategory.getName(); setResponsePage(new CodeAdministrationPage(getPageReference(), codeCategoryId, codeCategoryName)); } }; item.add(codeAdministrationLink); } }; dataView.setItemsPerPage(10); dataView.setItemReuseStrategy(ReuseIfModelsEqualStrategy.getInstance()); tableContainer.add(dataView); tableContainer.add(new PagingNavigator("navigator", dataView)); } catch (Throwable e) { throw new WebApplicationException("Failed to initialise the CodeCategoryAdministrationPage", e); } }
From source file:guru.mmp.application.web.template.pages.ConfigurationAdministrationPage.java
License:Apache License
/** * Constructs a new <code>ConfigurationAdministrationPage</code>. *//*from ww w.j a v a 2s .c om*/ public ConfigurationAdministrationPage() { super("Configuration"); try { /* * The table container, which allows the table and its associated navigator to be updated * using AJAX. */ WebMarkupContainer tableContainer = new WebMarkupContainer("tableContainer"); tableContainer.setOutputMarkupId(true); add(tableContainer); // The dialog used to confirm the removal of a configuration value RemoveDialog removeDialog = new RemoveDialog(tableContainer); add(removeDialog); // The "addLink" used to add a new configuration value Link<Void> addLink = new Link<Void>("addLink") { private static final long serialVersionUID = 1000000; @Override public void onClick() { setResponsePage(new AddConfigurationValuePage(getPageReference())); } }; tableContainer.add(addLink); FilteredConfigurationValueDataProvider dataProvider = new FilteredConfigurationValueDataProvider(); // The "filterForm" form Form<Void> filterForm = new Form<>("filterForm"); filterForm.setMarkupId("filterForm"); filterForm.setOutputMarkupId(true); // The "filter" field TextField<String> filterField = new TextField<>("filter", new PropertyModel<>(dataProvider, "filter")); filterForm.add(filterField); // The "filterButton" button Button filterButton = new Button("filterButton") { private static final long serialVersionUID = 1000000; @Override public void onSubmit() { } }; filterButton.setDefaultFormProcessing(true); filterForm.add(filterButton); // The "resetButton" button Button resetButton = new Button("resetButton") { private static final long serialVersionUID = 1000000; @Override public void onSubmit() { dataProvider.setFilter(""); } }; filterForm.add(resetButton); tableContainer.add(filterForm); // The configuration value data view DataView<ConfigurationValue> dataView = new DataView<ConfigurationValue>("configurationValue", dataProvider) { private static final long serialVersionUID = 1000000; @Override protected void populateItem(Item<ConfigurationValue> item) { item.add(new Label("key", new PropertyModel<String>(item.getModel(), "key"))); item.add(new Label("value", new PropertyModel<String>(item.getModel(), "value"))); // The "updateLink" link Link<Void> updateLink = new Link<Void>("updateLink") { private static final long serialVersionUID = 1000000; @Override public void onClick() { UpdateConfigurationValuePage page = new UpdateConfigurationValuePage(getPageReference(), item.getModel()); setResponsePage(page); } }; item.add(updateLink); // The "removeLink" link AjaxLink<Void> removeLink = new AjaxLink<Void>("removeLink") { private static final long serialVersionUID = 1000000; @Override public void onClick(AjaxRequestTarget target) { ConfigurationValue configuration = item.getModelObject(); if (configuration != null) { removeDialog.show(target, configuration); } else { target.add(tableContainer); } } }; item.add(removeLink); } }; dataView.setItemsPerPage(10); dataView.setItemReuseStrategy(ReuseIfModelsEqualStrategy.getInstance()); tableContainer.add(dataView); tableContainer.add(new PagingNavigator("navigator", dataView)); } catch (Throwable e) { throw new WebApplicationException("Failed to initialise the ConfigurationAdministrationPage", e); } }
From source file:guru.mmp.application.web.template.pages.GroupAdministrationPage.java
License:Apache License
/** * Constructs a new <code>GroupAdministrationPage</code>. *//*from w w w . ja va 2s. c o m*/ public GroupAdministrationPage() { super("Groups"); try { /* * Retrieve the list of user directories for the organisation the currently logged on user * is associated with and default to the first user directory. */ List<UserDirectory> userDirectories = getUserDirectories(); userDirectory = userDirectories.get(0); /* * The table container, which allows the table and its associated navigator to be updated * using AJAX. */ WebMarkupContainer tableContainer = new WebMarkupContainer("tableContainer"); tableContainer.setOutputMarkupId(true); add(tableContainer); // The dialog used to confirm the removal of a group RemoveDialog removeDialog = new RemoveDialog(tableContainer); add(removeDialog); // The "addLink" link Link<Void> addLink = new Link<Void>("addLink") { private static final long serialVersionUID = 1000000; @Override public void onClick() { AddGroupPage page = new AddGroupPage(getPageReference(), userDirectory.getId()); setResponsePage(page); } }; tableContainer.add(addLink); GroupDataProvider dataProvider = new GroupDataProvider(userDirectory.getId()); // The "userDirectoryDropdownMenu" dropdown button DropdownMenu<UserDirectory> userDirectoryDropdownMenu = new DropdownMenu<UserDirectory>( "userDirectoryDropdownMenu", new PropertyModel<>(this, "userDirectory"), userDirectories, "fa fa-users") { @Override protected String getDisplayValue(UserDirectory menuItem) { return menuItem.getName(); } @Override protected void onMenuItemSelected(AjaxRequestTarget target, UserDirectory menuItem) { dataProvider.setUserDirectoryId(userDirectory.getId()); if (target != null) { target.add(tableContainer); } } }; userDirectoryDropdownMenu.setVisible(userDirectories.size() > 1); tableContainer.add(userDirectoryDropdownMenu); // The group data view DataView<Group> dataView = new DataView<Group>("group", dataProvider) { private static final long serialVersionUID = 1000000; @Override protected void populateItem(Item<Group> item) { item.add(new Label("groupName", new PropertyModel<String>(item.getModel(), "groupName"))); item.add(new Label("description", new PropertyModel<String>(item.getModel(), "description"))); // The "updateLink" link Link<Void> updateLink = new Link<Void>("updateLink") { private static final long serialVersionUID = 1000000; @Override public void onClick() { UpdateGroupPage page = new UpdateGroupPage(getPageReference(), item.getModel()); setResponsePage(page); } }; item.add(updateLink); // The "removeLink" link AjaxLink<Void> removeLink = new AjaxLink<Void>("removeLink") { private static final long serialVersionUID = 1000000; @Override public void onClick(AjaxRequestTarget target) { Group group = item.getModelObject(); if (group != null) { removeDialog.show(target, group); } else { target.add(tableContainer); } } }; item.add(removeLink); } }; dataView.setItemsPerPage(10); dataView.setItemReuseStrategy(ReuseIfModelsEqualStrategy.getInstance()); tableContainer.add(dataView); tableContainer.add(new PagingNavigator("navigator", dataView)); } catch (Throwable e) { throw new WebApplicationException("Failed to initialise the GroupAdministrationPage", e); } }