List of usage examples for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow getContentId
public String getContentId()
From source file:org.wicketTutorial.modalwindow.HomePage.java
License:Apache License
public HomePage(final PageParameters parameters) { super(parameters); final ModalWindow modalWindow = new ModalWindow("modalWindow"); Label label = new Label(modalWindow.getContentId(), "I'm a modal window!"); modalWindow.setContent(label);/*from w w w . j a v a2s . c o m*/ modalWindow.setTitle("Modal window"); add(modalWindow); add(new AjaxLink("openWindow") { @Override public void onClick(AjaxRequestTarget target) { modalWindow.show(target); } }); }
From source file:org.xaloon.wicket.component.classifier.panel.NewClassifierItemPanel.java
License:Apache License
/** * Construct./*from w ww.ja v a2 s.c o m*/ * * @param addNewClassifierModalWindow * @param pageParameters */ public NewClassifierItemPanel(ModalWindow addNewClassifierModalWindow, PageParameters pageParameters) { super(addNewClassifierModalWindow.getContentId()); this.addNewClassifierModalWindow = addNewClassifierModalWindow; classifierType = pageParameters.get(ClassifiersPanel.PARAM_CLASSIFIER_TYPE).toString(); if (pageParameters.get(ClassifierConstants.PARENT_ITEM) != null) { parentClassifierItemCode = pageParameters.get(ClassifierConstants.PARENT_ITEM).toString(); } }
From source file:org.xaloon.wicket.component.classifier.panel.NewClassifierPanel.java
License:Apache License
/** * Construct.//from ww w.j a v a2 s . c o m * * @param addNewClassifierModalWindow * @param pageParameters */ public NewClassifierPanel(ModalWindow addNewClassifierModalWindow, PageParameters pageParameters) { super(addNewClassifierModalWindow.getContentId()); this.addNewClassifierModalWindow = addNewClassifierModalWindow; }
From source file:org.xaloon.wicket.plugin.admin.PluginConfigurationPanel.java
License:Apache License
/** * Construct./*from ww w . ja v a 2s. c o m*/ * * @param pluginConfigModalWindow * * @param pluginModel */ public PluginConfigurationPanel(ModalWindow pluginConfigModalWindow, IModel<Plugin> pluginModel) { super(pluginConfigModalWindow.getContentId(), pluginModel); this.pluginConfigModalWindow = pluginConfigModalWindow; }
From source file:org.xaloon.wicket.plugin.image.panel.ImagePanel.java
License:Apache License
@Override protected void onBeforeRender() { super.onBeforeRender(); removeAll();/*from w w w . j a v a2 s .c o m*/ final ImageComposition image = getModelObject(); // Add show temporary image FileDescriptor temporaryFiledeDescriptor = image.getImage().getThumbnail(); if (temporaryFiledeDescriptor == null) { temporaryFiledeDescriptor = image.getImage(); } if (temporaryFiledeDescriptor != null && temporaryFiledeDescriptor.getImageInputStreamContainer() == null) { if (temporaryFiledeDescriptor.isExternal()) { temporaryFiledeDescriptor.setImageInputStreamContainer( new UrlInputStreamContainer(temporaryFiledeDescriptor.getPath())); } else { temporaryFiledeDescriptor.setImageInputStreamContainer(new ByteArrayAsInputStreamContainer( fileRepositoryFacade.getFileByPath(temporaryFiledeDescriptor.getPath()))); } } TemporaryResource temporaryResource = new TemporaryResource(temporaryFiledeDescriptor); Image temporaryImage = new NonCachingImage("temporary-image", temporaryResource); temporaryImage.add(AttributeModifier.replace(HtmlElementEnum.WIDTH.value(), String.valueOf(imageWidth))); temporaryImage.add(AttributeModifier.replace(HtmlElementEnum.HEIGHT.value(), String.valueOf(imageHeight))); temporaryImage.setVisible(!temporaryResource.isEmpty()); add(temporaryImage); // Add delete image link add(new ConfirmationAjaxLink<Void>("delete-image-link") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { deleteFileDescriptor(image); Component componentToRefresh = getOnCloseRefreshComponent(); if (componentToRefresh != null) { target.add(componentToRefresh); } } }.setVisible(securityFacade.hasAny(GallerySecurityAuthorities.IMAGE_DELETE))); // Add the modal window to edit image information final ModalWindow imageInformationModalWindow = new CustomModalWindow("modal-image-information", "Image information") { private static final long serialVersionUID = 1L; @Override protected void addComponentsToRefresh(java.util.List<Component> components) { components.add(ImagePanel.this); }; }; imageInformationModalWindow.setContent(new ImageDescriptionPanel(imageInformationModalWindow.getContentId(), new Model<org.xaloon.core.api.image.model.Image>(image.getImage())) { private static final long serialVersionUID = 1L; @Override protected void onImageUpdate(AjaxRequestTarget target, org.xaloon.core.api.image.model.Image entity) { // Usually parent of this panel should be responsible to save // new entity, so we just update existing one here if (entity.getId() != null) { albumFacade.save(entity); } imageInformationModalWindow.close(target); } }); add(imageInformationModalWindow); // Add edit image metadata modal window add(new AjaxLink<Void>("edit-information") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { imageInformationModalWindow.show(target); } }.setVisible(securityFacade.hasAny(GallerySecurityAuthorities.IMAGE_EDIT))); }
From source file:org.xaloon.wicket.plugin.image.panel.SingleFileUploadPanel.java
License:Apache License
/** * Construct./* w w w . ja v a2 s . com*/ * * @param model * @param window */ public SingleFileUploadPanel(ModalWindow window, IModel<org.xaloon.core.api.image.model.Image> model) { super(window.getContentId(), model); this.window = window; add(new SingleFileUploadForm("file-upload-form", new CompoundPropertyModel<org.xaloon.core.api.image.model.Image>(model))); }
From source file:org.xaloon.wicket.plugin.user.admin.panel.CheckboxMultipleChoiceManagement.java
License:Apache License
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override/*w ww .j a v a 2 s .c o m*/ protected void onBeforeRender() { super.onBeforeRender(); removeAll(); // Add the modal window final ModalWindow addGroupModalWindow = new CustomModalWindow("modal-assign-entities", "Assign something") { private static final long serialVersionUID = 1L; @Override protected void addComponentsToRefresh(List<Component> components) { CheckboxMultipleChoiceManagement.this.addComponentsToRefresh(components); } }; add(addGroupModalWindow); // Create and set form container panel FormContainerPanel formContainerPanel = new FormContainerPanel(addGroupModalWindow.getContentId()); addGroupModalWindow.setContent(formContainerPanel); // Create and add form Form form = new Form("form"); formContainerPanel.setForm(form); // Create and add selection choices to form CheckBoxMultipleChoice choices = new CheckBoxMultipleChoice("choices", Model.of(selectedEntities), availableEntitiesToSelect, choiceRenderer); form.add(choices); // Add submit button to form form.add(new AjaxButton("submit") { /** * */ private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { onFormSubmit(target); addGroupModalWindow.close(target); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { } }); // Add assign entities link add(new AjaxLink<Void>("link-assign-entities") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { addGroupModalWindow.show(target); } }); }
From source file:org.xaloon.wicket.plugin.user.admin.panel.GroupDetailPanelTest.java
License:Apache License
/** * @throws Exception/*w ww . j ava 2s . co m*/ */ @Test public void testAssignRole() throws Exception { // TEST ASSIGN ROLE TO GROUP Assert.assertNotNull(tester.getTagByWicketId("link-assign-entities")); tester.clickLink("id:role-admin:choice-management:link-assign-entities"); tester.assertNoErrorMessage(); ModalWindow modalWindow = (ModalWindow) tester .getComponentFromLastRenderedPage("id:role-admin:choice-management:modal-assign-entities"); String modalPath = modalWindow.getPageRelativePath() + ":" + modalWindow.getContentId(); Assert.assertTrue(modalWindow.isVisible()); // Submit the form String formPath = modalPath + ":form"; FormTester form = tester.newFormTester(formPath); form.selectMultiple("choices", new int[] { 1 }); Mockito.when(groupService.assignChildren((SecurityGroup) Matchers.anyObject(), Matchers.anyListOf(SecurityRole.class))).thenAnswer(new Answer<SecurityGroup>() { @SuppressWarnings("unchecked") @Override public SecurityGroup answer(InvocationOnMock invocation) throws Throwable { Object[] args = invocation.getArguments(); List<SecurityRole> selections = (List<SecurityRole>) args[1]; Assert.assertEquals(1, selections.size()); Assert.assertEquals(availableRoles.get(1), selections.get(0)); return null; } }); // Submit ajax form tester.executeAjaxEvent(formPath + ":submit", "onclick"); }
From source file:org.xaloon.wicket.plugin.user.admin.panel.GroupsPanel.java
License:Apache License
@Override protected void onBeforeRender() { super.onBeforeRender(); removeAll();//w ww .j a v a2 s. com // Add paging navigation container with navigation toolbar final DecoratedPagingNavigatorContainer<SecurityGroup> dataContainer = new DecoratedPagingNavigatorContainer<SecurityGroup>( "container", getCurrentRedirectLink()); dataContainer.setOutputMarkupId(true); addOrReplace(dataContainer); // Add blog list data view final DataView<SecurityGroup> securityGroupDataView = new DataView<SecurityGroup>("security-groups", new JpaSecurityGroupDataProvider()) { private static final long serialVersionUID = 1L; @Override protected void populateItem(Item<SecurityGroup> item) { final SecurityGroup group = item.getModelObject(); PageParameters pageParams = new PageParameters(); pageParams.add(Bookmarkable.PARAM_PATH, group.getPath()); BookmarkablePageLink<Void> groupLink = new BookmarkablePageLink<Void>("groupDetails", GroupDetailPage.class, pageParams); item.add(groupLink); groupLink.add(new Label("name", new Model<String>(group.getName()))); item.add(new ConfirmationAjaxLink<Void>("delete") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { groupService.delete(group); target.add(dataContainer); } }); } }; dataContainer.addAbstractPageableView(securityGroupDataView); // Add the modal window to create new group final ModalWindow addNewGroupModalWindow = new CustomModalWindow("modal-new-group", "New group") { private static final long serialVersionUID = 1L; @Override protected void addComponentsToRefresh(java.util.List<Component> components) { components.add(GroupsPanel.this); }; }; addNewGroupModalWindow.setContent(new CreateNewEntityPanel<SecurityGroup>( addNewGroupModalWindow.getContentId(), new Model<SecurityGroup>(groupService.newAuthority())) { private static final long serialVersionUID = 1L; @Override protected void onNewEntitySubmit(AjaxRequestTarget target, SecurityGroup entity) { groupService.save(entity); addNewGroupModalWindow.close(target); } }); add(addNewGroupModalWindow); // add new group link add(new AjaxLink<Void>("add-new-group") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { addNewGroupModalWindow.show(target); } }); }
From source file:org.xaloon.wicket.plugin.user.admin.panel.GroupsPanelTest.java
License:Apache License
/** * @throws Exception//from ww w. ja va 2 s . com */ @Test public void testGroupPanelAuthorized() throws Exception { MockedApplication app = createMockedApplication(); WicketTester tester = new WicketTester(app); // Set security to True by default when(app.getSecurityFacade().hasAny(SecurityAuthorities.SYSTEM_ADMINISTRATOR)).thenReturn(true); // Return at least one group when(groupService.getCount()).thenReturn(1L); SecurityGroup group = mock(SecurityGroup.class); when(group.getPath()).thenReturn("group-name"); List<SecurityGroup> groups = new ArrayList<SecurityGroup>(); groups.add(group); when(groupService.getAuthorities(0, 1)).thenReturn(groups); SecurityGroup securityGroup = new JpaGroup(); when(groupService.newAuthority()).thenReturn(securityGroup); tester.startComponentInPage(new GroupsPanel("id", new PageParameters())); // Test if there are any items displayed assertNotNull(tester.getTagByWicketId("container")); assertNotNull(tester.getTagByWicketId("security-groups")); assertEquals(1, tester.getTagsByWicketId("name").size()); // Test creating new group tester.clickLink("id:add-new-group"); tester.assertNoErrorMessage(); // Get the modal window and submit the form ModalWindow modal = (ModalWindow) tester.getComponentFromLastRenderedPage("id:modal-new-group"); tester.isVisible(modal.getPageRelativePath()); String modalPath = modal.getPageRelativePath() + ":" + modal.getContentId(); // Close and re-open form closeModalWindow(modal, tester); tester.clickLink("id:add-new-group"); tester.assertNoErrorMessage(); modal = (ModalWindow) tester.getComponentFromLastRenderedPage("id:modal-new-group"); // Submit the form String formPath = modalPath + ":new-entity"; FormTester form = tester.newFormTester(formPath); form.setValue("name", "testValue"); // Submit ajax form tester.executeAjaxEvent(formPath + ":submit", "onclick"); // Validate result tester.assertNoErrorMessage(); Assert.assertEquals("testValue", securityGroup.getName()); }