List of usage examples for org.apache.wicket Component RENDER
Action RENDER
To view the source code for org.apache.wicket Component RENDER.
Click Source Link
From source file:org.devgateway.eudevfin.mcm.NavbarInitializer.java
License:Open Source License
@WicketNavbarComponentInitializer(position = Navbar.ComponentPosition.RIGHT, order = 7) public static Component newAdminNavbarButton(final Page page) { final NavbarDropDownButton navbarDropDownButton = new RepairedNavbarDropDownButton( new StringResourceModel("navbar.admin", page, null, null)) { @Override//from www. ja v a 2 s . co m public boolean isActive(final Component item) { return false; } @Override protected List<AbstractLink> newSubMenuButtons(final String buttonMarkupId) { final List<AbstractLink> list = new ArrayList<>(); list.add(new MenuHeader(new StringResourceModel("navbar.admin.header", this, null, null))); list.add(new MenuDivider()); list.add(new MenuBookmarkablePageLink<ListPersistedUsersPage>(ListPersistedUsersPage.class, null, new StringResourceModel("navbar.admin.users", this, null, null)) .setIconType(IconType.thlist)); list.add( new MenuBookmarkablePageLink<ListPersistedUserGroupsPage>(ListPersistedUserGroupsPage.class, null, new StringResourceModel("navbar.admin.groups", this, null, null)) .setIconType(IconType.list)); list.add(new MenuBookmarkablePageLink<ListOrganizationsPage>(ListOrganizationsPage.class, null, new StringResourceModel("navbar.admin.orgs", this, null, null)).setIconType(IconType.leaf)); list.add(new MenuBookmarkablePageLink<EditNonFlowItemsPage>(EditNonFlowItemsPage.class, null, new StringResourceModel("navbar.admin.nonflow", this, null, null)) .setIconType(IconType.globe)); DropDownSubMenu publishReports = new DropDownSubMenu( new StringResourceModel("navbar.reports.publish", this, null, null)) { @Override public boolean isActive(Component item) { return false; } @Override protected List<AbstractLink> newSubMenuButtons(String buttonMarkupId) { List<AbstractLink> list = new ArrayList<>(); PageParameters paramsAQ = new PageParameters(); paramsAQ.set("reportType", "aq"); list.add(new MenuBookmarkablePageLink<PublishReports>(PublishReports.class, paramsAQ, new StringResourceModel("navbar.reports.export.aq", this, null, null))); PageParameters paramsDAC1 = new PageParameters(); paramsDAC1.set("reportType", "dac1"); list.add((AbstractLink) new MenuBookmarkablePageLink<PublishReports>(PublishReports.class, paramsDAC1, new StringResourceModel("navbar.reports.export.dac1", this, null, null))); PageParameters paramsDAC2a = new PageParameters(); paramsDAC2a.set("reportType", "dac2a"); list.add((AbstractLink) new MenuBookmarkablePageLink<PublishReports>(PublishReports.class, paramsDAC2a, new StringResourceModel("navbar.reports.export.dac2a", this, null, null))); return list; } }; publishReports.setIconType(IconType.inbox); MetaDataRoleAuthorizationStrategy.authorize(publishReports, Component.RENDER, AuthConstants.Roles.ROLE_SUPERVISOR); list.add(publishReports); DropDownSubMenu adminRates = new DropDownSubMenu( new StringResourceModel("navbar.admin.rates", this, null, null)) { @Override public boolean isActive(Component item) { return false; } @Override protected List<AbstractLink> newSubMenuButtons(String buttonMarkupId) { List<AbstractLink> list = new ArrayList<>(); list.add(new MenuBookmarkablePageLink<ListHistoricalExchangeRatePage>( ListHistoricalExchangeRatePage.class, null, new StringResourceModel("navbar.admin.rates.historical", this, null, null)) .setIconType(IconType.folderclose)); list.add(new MenuBookmarkablePageLink<OnlineExchangeRatePage>(OnlineExchangeRatePage.class, null, new StringResourceModel("navbar.admin.rates.online", this, null, null)) .setIconType(IconType.random)); return list; } }; adminRates.setIconType(IconType.retweet); list.add(adminRates); /* hide the system menu for the moment // list.add((AbstractLink) new MenuBookmarkablePageLink<SystemMaintenance>( // SystemMaintenance.class, null, new StringResourceModel("navbar.admin.maintenance", this, null, // null)).setIconType(IconType.wrench).setEnabled(false)); */ return list; } }; navbarDropDownButton.setIconType(IconType.eyeopen); navbarDropDownButton.add(new DropDownAutoOpen()); MetaDataRoleAuthorizationStrategy.authorize(navbarDropDownButton, Component.RENDER, AuthConstants.Roles.ROLE_SUPERVISOR); return navbarDropDownButton; }
From source file:org.devgateway.eudevfin.mcm.NavbarInitializer.java
License:Open Source License
@WicketNavbarComponentInitializer(position = Navbar.ComponentPosition.RIGHT, order = 30) public static Component accountButton(final Page page) { final NavbarDropDownButton accountMenu = new RepairedNavbarDropDownButton( new StringResourceModel("navbar.account.user", page, null, null)) { @Override// w ww.j a v a2 s. c o m public boolean isActive(final Component item) { return false; } @Override protected List<AbstractLink> newSubMenuButtons(final String buttonMarkupId) { final List<AbstractLink> list = new ArrayList<>(); final MenuBookmarkablePageLink<EditPersistedUserPage> accountNavbarButton = new MenuBookmarkablePageLink<EditPersistedUserPage>( EditPersistedUserPage.class, new StringResourceModel("navbar.account", page, null, null)); accountNavbarButton.setIconType(IconType.edit); MetaDataRoleAuthorizationStrategy.authorize(accountNavbarButton, Component.RENDER, AuthConstants.Roles.ROLE_USER); MetaDataRoleAuthorizationStrategy.authorize(accountNavbarButton, Component.RENDER, AuthConstants.Roles.ROLE_VIEWER); list.add(accountNavbarButton); final MenuBookmarkablePageLink<LogoutPage> logoutPageNavbarButton = new MenuBookmarkablePageLink<LogoutPage>( LogoutPage.class, new StringResourceModel("navbar.logout", page, null, null)); logoutPageNavbarButton.setIconType(IconType.off); MetaDataRoleAuthorizationStrategy.authorize(logoutPageNavbarButton, Component.RENDER, AuthConstants.Roles.ROLE_USER); MetaDataRoleAuthorizationStrategy.authorize(logoutPageNavbarButton, Component.RENDER, AuthConstants.Roles.ROLE_VIEWER); list.add(logoutPageNavbarButton); return list; } }; accountMenu.setIconType(IconType.user); MetaDataRoleAuthorizationStrategy.authorize(accountMenu, Component.RENDER, AuthConstants.Roles.ROLE_USER); MetaDataRoleAuthorizationStrategy.authorize(accountMenu, Component.RENDER, AuthConstants.Roles.ROLE_VIEWER); return accountMenu; }
From source file:org.devgateway.eudevfin.projects.module.NavbarInitializer.java
@WicketNavbarComponentInitializer(position = Navbar.ComponentPosition.LEFT, order = 2) public static Component newProjectsNavbarMenu(final Page page) { final NavbarDropDownButton navbarDropDownButton = new RepairedNavbarDropDownButton( new StringResourceModel("navbar.projects", page, null, null)) { @Override// w w w . j a v a 2s. c o m public boolean isActive(final Component item) { return false; } @SuppressWarnings("Convert2Diamond") @Override protected List<AbstractLink> newSubMenuButtons(final String buttonMarkupId) { final List<AbstractLink> list = new ArrayList<>(); list.add(new MenuHeader(new StringResourceModel("navbar.projects.header", this, null))); list.add(new MenuDivider()); final MenuBookmarkablePageLink<NewProjectPage> newProject = new MenuBookmarkablePageLink<NewProjectPage>( NewProjectPage.class, null, new StringResourceModel("navbar.projects.newproject", page, null)); newProject.setIconType(IconType.plus); MetaDataRoleAuthorizationStrategy.authorize(newProject, Component.RENDER, AuthConstants.Roles.ROLE_PROJECTS_MFA); MetaDataRoleAuthorizationStrategy.authorize(newProject, Component.RENDER, AuthConstants.Roles.ROLE_SUPERVISOR); list.add(newProject); final MenuBookmarkablePageLink<AllProjectsPage> allProjects = new MenuBookmarkablePageLink<AllProjectsPage>( AllProjectsPage.class, null, new StringResourceModel("navbar.projects.allprojects", page, null)); allProjects.setIconType(IconType.list); MetaDataRoleAuthorizationStrategy.authorize(allProjects, Component.RENDER, AuthConstants.Roles.ROLE_PROJECTS_MFA); MetaDataRoleAuthorizationStrategy.authorize(allProjects, Component.RENDER, AuthConstants.Roles.ROLE_PROJECTS_NGO); MetaDataRoleAuthorizationStrategy.authorize(allProjects, Component.RENDER, AuthConstants.Roles.ROLE_SUPERVISOR); list.add(allProjects); return list; } }; navbarDropDownButton.setIconType(IconType.plus); navbarDropDownButton.add(new DropDownAutoOpen()); MetaDataRoleAuthorizationStrategy.authorize(navbarDropDownButton, Component.RENDER, AuthConstants.Roles.ROLE_PROJECTS_MFA); MetaDataRoleAuthorizationStrategy.authorize(navbarDropDownButton, Component.RENDER, AuthConstants.Roles.ROLE_PROJECTS_NGO); MetaDataRoleAuthorizationStrategy.authorize(navbarDropDownButton, Component.RENDER, AuthConstants.Roles.ROLE_SUPERVISOR); return navbarDropDownButton; }
From source file:org.devgateway.eudevfin.reports.DashboardsConfiguration.java
License:Open Source License
@PostConstruct @DependsOn(value = "wicketSpringApplication") private void addReportsNavbar() { NavbarButton<ReportsPage> reportsPageNavbarButton = new NavbarButton<ReportsPage>(ReportsPage.class, new StringResourceModel("navbar.reports", null, null)).setIconType(IconType.thlist); MetaDataRoleAuthorizationStrategy.authorize(reportsPageNavbarButton, Component.RENDER, AuthConstants.Roles.ROLE_USER); navbar.addComponents(NavbarComponents.transform(Navbar.ComponentPosition.LEFT, reportsPageNavbarButton)); }
From source file:org.devgateway.eudevfin.reports.NavbarInitializer.java
License:Open Source License
@WicketNavbarComponentInitializer(position = Navbar.ComponentPosition.LEFT, order = 3) public static Component newReportsNavbarMenu(Page page) { NavbarDropDownButton navbarDropDownButton = new RepairedNavbarDropDownButton( new StringResourceModel("navbar.reports", page, null, null)) { @Override/* w ww . j av a2 s .com*/ public boolean isActive(Component item) { return false; } @Override protected List<AbstractLink> newSubMenuButtons(String buttonMarkupId) { List<AbstractLink> list = new ArrayList<>(); list.add(new MenuHeader(new StringResourceModel("navbar.reports.header", this, null, null))); list.add(new MenuDivider()); BootstrapBookmarkablePageLink<ReportsPage> odaAtGlance = new MenuBookmarkablePageLink<ReportsPage>( ReportsPage.class, null, new StringResourceModel("navbar.dashboard", this, null, null)) .setIconType(IconType.picture); MetaDataRoleAuthorizationStrategy.authorize(odaAtGlance, Component.RENDER, AuthConstants.Roles.ROLE_USER); list.add(odaAtGlance); DropDownSubMenu exportReports = new DropDownSubMenu( new StringResourceModel("navbar.reports.export", this, null, null)) { @Override public boolean isActive(Component item) { return false; } @Override protected List<AbstractLink> newSubMenuButtons(String buttonMarkupId) { List<AbstractLink> list = new ArrayList<>(); //TODO: Wrap creation of links with something similar to TransactionPage.getTransactionLinks() PageParameters paramsAQ = new PageParameters(); paramsAQ.set("reportType", "aq"); list.add(new MenuBookmarkablePageLink<ReportsExport>(ReportsExport.class, paramsAQ, new StringResourceModel("navbar.reports.export.aq", this, null, null))); PageParameters paramsDAC1 = new PageParameters(); paramsDAC1.set("reportType", "dac1"); list.add((AbstractLink) new MenuBookmarkablePageLink<ReportsExport>(ReportsExport.class, paramsDAC1, new StringResourceModel("navbar.reports.export.dac1", this, null, null))); PageParameters paramsDAC2a = new PageParameters(); paramsDAC2a.set("reportType", "dac2a"); list.add((AbstractLink) new MenuBookmarkablePageLink<ReportsExport>(ReportsExport.class, paramsDAC2a, new StringResourceModel("navbar.reports.export.dac2a", this, null, null))); return list; } }; exportReports.setIconType(IconType.resizehorizontal); MetaDataRoleAuthorizationStrategy.authorize(exportReports, Component.RENDER, AuthConstants.Roles.ROLE_USER); list.add(exportReports); DropDownSubMenu customReports = new DropDownSubMenu( new StringResourceModel("navbar.customreports", this, null, null)) { @Override public boolean isActive(Component item) { return false; } @Override protected List<AbstractLink> newSubMenuButtons(String buttonMarkupId) { List<AbstractLink> list = new ArrayList<>(); list.add(new MenuBookmarkablePageLink<ReportsCountrySectorFilter>( ReportsCountrySectorFilter.class, null, new StringResourceModel("navbar.customreports.countrysector", this, null, null)) .setIconType(IconType.picture)); list.add(new MenuBookmarkablePageLink<ReportsCountryInstitutionFilter>( ReportsCountryInstitutionFilter.class, null, new StringResourceModel( "navbar.customreports.countryinstitution", this, null, null)) .setIconType(IconType.picture)); list.add(new MenuBookmarkablePageLink<ReportsInstitutionTypeOfAidFilter>( ReportsInstitutionTypeOfAidFilter.class, null, new StringResourceModel( "navbar.customreports.institutiontypeofaid", this, null, null)) .setIconType(IconType.picture)); list.add(new MenuBookmarkablePageLink<ReportsImplementationStatusFilter>( ReportsImplementationStatusFilter.class, null, new StringResourceModel( "navbar.customreports.implementationstatus", this, null, null)) .setIconType(IconType.picture)); return list; } }; customReports.setIconType(IconType.file); MetaDataRoleAuthorizationStrategy.authorize(customReports, Component.RENDER, AuthConstants.Roles.ROLE_USER); MetaDataRoleAuthorizationStrategy.authorize(customReports, Component.RENDER, AuthConstants.Roles.ROLE_VIEWER); list.add(customReports); @SuppressWarnings("serial") MenuBookmarkablePageLink<ReportsPage> reportBuilderLink = new MenuBookmarkablePageLink<ReportsPage>( SaikuRedirectPage.class, null, new StringResourceModel("navbar.reportsbuilder", this, null, null)) { @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); tag.put("target", "_blank"); } }; reportBuilderLink.setIconType(IconType.play).setEnabled(true); MetaDataRoleAuthorizationStrategy.authorize(reportBuilderLink, Component.RENDER, AuthConstants.Roles.ROLE_USER); list.add(reportBuilderLink); /* list.add(new MenuBookmarkablePageLink<ReportsExport>( ReportsExport.class, null, new StringResourceModel( "navbar.reports.export", this, null, null)) .setIconType(IconType.thlist)); */ return list; } }; navbarDropDownButton.setIconType(IconType.thlarge); navbarDropDownButton.add(new DropDownAutoOpen()); MetaDataRoleAuthorizationStrategy.authorize(navbarDropDownButton, Component.RENDER, AuthConstants.Roles.ROLE_USER); MetaDataRoleAuthorizationStrategy.authorize(navbarDropDownButton, Component.RENDER, AuthConstants.Roles.ROLE_VIEWER); return navbarDropDownButton; }
From source file:org.devgateway.eudevfin.sheetexp.ui.NavbarInitializer.java
License:Open Source License
@WicketNavbarComponentInitializer(position = Navbar.ComponentPosition.LEFT, order = 4) public static Component newExportSpreadSheetButton(final Page page) { final NavbarDropDownButton exportMenu = new RepairedNavbarDropDownButton( new StringResourceModel("navbar.spreadsheets.export", page, null, null)) { @Override/*ww w. ja v a 2 s . c o m*/ public boolean isActive(final Component item) { return false; } @Override protected List<AbstractLink> newSubMenuButtons(final String buttonMarkupId) { final List<AbstractLink> list = new ArrayList<>(); list.add(new MenuHeader(new StringResourceModel("navbar.export.header", this, null, null))); list.add(new MenuDivider()); final PageParameters paramsCRS = new PageParameters(); paramsCRS.set(MetadataConstants.REPORT_TYPE_PARAM, MetadataConstants.CRS_REPORT_TYPE); list.add((AbstractLink) new MenuBookmarkablePageLink<ExportSpreadsheetsPage>( ExportSpreadsheetsPage.class, paramsCRS, new StringResourceModel("navbar.reports.export.crs", this, null, null)).setEnabled(true)); final PageParameters paramsFSS = new PageParameters(); paramsFSS.set(MetadataConstants.REPORT_TYPE_PARAM, MetadataConstants.FSS_REPORT_TYPE); list.add((AbstractLink) new MenuBookmarkablePageLink<ExportSpreadsheetsPage>( ExportSpreadsheetsPage.class, paramsFSS, new StringResourceModel("navbar.reports.export.fss", this, null, null)).setEnabled(true)); final PageParameters paramsIATI = new PageParameters(); paramsIATI.set("reportType", "iati"); list.add((AbstractLink) new MenuBookmarkablePageLink<ExportSpreadsheetsPage>( ExportSpreadsheetsPage.class, paramsIATI, new StringResourceModel("navbar.reports.export.iati", this, null, null)).setEnabled(true)); return list; } }; exportMenu.setIconType(IconType.arrowdown); exportMenu.add(new DropDownAutoOpen()); MetaDataRoleAuthorizationStrategy.authorize(exportMenu, Component.RENDER, AuthConstants.Roles.ROLE_USER); return exportMenu; }
From source file:org.devgateway.eudevfin.ui.common.permissions.PermissionAuthorizationStrategy.java
License:Open Source License
/** * {@inheritDoc IAuthorizationStrategy#isActionAuthorized} */// w w w . j av a 2s . c o m @Override public boolean isActionAuthorized(Component component, Action action) { if (action == Component.ENABLE) return true; // we don't have permissions for enable, yet if (!(component instanceof PermissionAwareComponent)) return true; if (action != Component.RENDER) throw new AssertionError("was assuming that action is render from this step forward"); PermissionAwareComponent pwc = (PermissionAwareComponent) component; Page page = component.getPage(); if (page == null || !(page instanceof PermissionAwarePage)) return true; //not a permission aware page => other strategies decide ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder .getRequestAttributes(); HttpServletRequest httpServletRequest = requestAttributes.getRequest(); String transactionType = httpServletRequest.getParameter(Constants.PARAM_TRANSACTION_TYPE); if (transactionType == null || transactionType.isEmpty()) return true; //not a transaction aware scope => others decide HashMap<String, RoleActionMapping> permissions = ((PermissionAwarePage) page).getPermissions(); return checkPermissions(pwc, transactionType, permissions); }
From source file:org.devgateway.toolkit.forms.wicket.components.form.FileInputBootstrapFormComponentWrapper.java
License:Open Source License
/** * already uploaded files section/* www . ja v a 2s. c o m*/ */ private void addAlreadyUploadedFilesComponent() { alreadyUploadedFiles = new WebMarkupContainer("alreadyUploadedFiles") { private static final long serialVersionUID = 1L; @Override protected void onInitialize() { super.onInitialize(); setVisibilityAllowed(isVisibleAlreadyUploadedFiles()); } }; alreadyUploadedFiles.setOutputMarkupPlaceholderTag(true); alreadyUploadedFiles.setOutputMarkupId(true); add(alreadyUploadedFiles); alreadyUploadedFiles .add(new Label("uploadedFilesTitle", new StringResourceModel("uploadedFilesTitle", this, null))); AbstractReadOnlyModel<List<FileMetadata>> alreadyUploadedFilesModel = new AbstractReadOnlyModel<List<FileMetadata>>() { private static final long serialVersionUID = 1L; @Override public List<FileMetadata> getObject() { List<FileMetadata> fileObject = new ArrayList<>(); // get only the already uploaded files for (FileMetadata file : filesModel) { if (!file.isNew()) { fileObject.add(file); } } return fileObject; } }; ListView<FileMetadata> list = new ListView<FileMetadata>("list", alreadyUploadedFilesModel) { private static final long serialVersionUID = 1L; private List<IndicatingAjaxLink<Void>> deleteButtons = new ArrayList<>(); @Override protected void populateItem(final ListItem<FileMetadata> item) { // make file name clickable Link<FileMetadata> downloadLink = new Link<FileMetadata>("downloadLink", item.getModel()) { private static final long serialVersionUID = 1L; @Override public void onClick() { final FileMetadata modelObject = getModelObject(); AbstractResourceStreamWriter rstream = new AbstractResourceStreamWriter() { private static final long serialVersionUID = 1L; @Override public void write(final OutputStream output) throws IOException { output.write(modelObject.getContent().getBytes()); } @Override public String getContentType() { return modelObject.getContentType(); } }; ResourceStreamRequestHandler handler = new ResourceStreamRequestHandler(rstream, modelObject.getName()); handler.setContentDisposition(ContentDisposition.ATTACHMENT); getRequestCycle().scheduleRequestHandlerAfterCurrent(handler); } }; downloadLink.add(new Label("downloadText", item.getModelObject().getName())); downloadLink.add(new TooltipBehavior(new StringResourceModel("downloadUploadedFileTooltip", FileInputBootstrapFormComponentWrapper.this, null), TOOLTIP_CONFIG)); item.add(downloadLink); Link<FileMetadata> download = new CustomDownloadLink("download", item.getModel()); item.add(download); IndicatingAjaxLink<Void> delete = new IndicatingAjaxLink<Void>("delete") { private static final long serialVersionUID = 1L; @SuppressWarnings("unchecked") @Override public void onClick(final AjaxRequestTarget target) { filesModel.remove(item.getModelObject()); FileInputBootstrapFormComponentWrapper.this.getModel().setObject((T) filesModel); target.add(alreadyUploadedFiles); } }; delete.add(new IconBehavior(GlyphIconType.remove)); delete.add(new TooltipBehavior(new StringResourceModel("removeUploadedFileTooltip", FileInputBootstrapFormComponentWrapper.this, null), TOOLTIP_CONFIG)); delete.setVisible(true); item.add(delete); deleteButtons.add(delete); // there are situation when we want to display the delete button // only to admins if (visibleOnlyToAdmin) { MetaDataRoleAuthorizationStrategy.authorize(delete, Component.RENDER, SecurityConstants.Roles.ROLE_ADMIN); } if (disableDeleteButton) { delete.setVisibilityAllowed(false); } } @Override public void onEvent(final IEvent<?> event) { /* * disable 'delete' buttons based on the form state */ if (event.getPayload() instanceof EditingDisabledEvent) { for (IndicatingAjaxLink<?> del : deleteButtons) { del.setVisibilityAllowed(false); } } if (event.getPayload() instanceof EditingEnabledEvent) { for (IndicatingAjaxLink<?> del : deleteButtons) { del.setVisibilityAllowed(true); } } } }; alreadyUploadedFiles.add(list); }
From source file:org.devgateway.toolkit.forms.wicket.components.form.FileInputBootstrapFormComponentWrapper.java
License:Open Source License
private void addBootstrapFileInputComponent() { // this is where the newly uploaded files are saved final IModel<List<FileUpload>> internalUploadModel = new ListModel<>(); /*//from w ww.j ava2 s .c o m * some customization of the BootstrapFileInput Component */ FileInputConfig fileInputConfig = new FileInputConfig(); fileInputConfig.put(new Key<String>("browseLabel"), new StringResourceModel("browseLabel", FileInputBootstrapFormComponentWrapper.this, null) .getString()); fileInputConfig.put(new Key<String>("uploadClass"), "btn btn-blue"); fileInputConfig.put(new Key<String>("browseClass"), "btn btn-blue"); bootstrapFileInput = new BootstrapFileInput("bootstrapFileInput", internalUploadModel, fileInputConfig) { private static final long serialVersionUID = 1L; @SuppressWarnings("unchecked") @Override protected void onSubmit(final AjaxRequestTarget target) { super.onSubmit(target); List<FileUpload> fileUploads = internalUploadModel.getObject(); if (fileUploads != null) { // check if we uploaded too many files if (maxFiles > 0 && filesModel.size() + fileUploads.size() > maxFiles) { if (maxFiles == 1) { FileInputBootstrapFormComponentWrapper.this.fatal(new StringResourceModel("OneUpload", FileInputBootstrapFormComponentWrapper.this, null).getString()); } else { FileInputBootstrapFormComponentWrapper.this .fatal(new StringResourceModel("tooManyFiles", FileInputBootstrapFormComponentWrapper.this, Model.of(maxFiles)) .getString()); } FileInputBootstrapFormComponentWrapper.this.invalid(); } else { // convert the uploaded files to the internal structure // and update the model for (FileUpload upload : fileUploads) { FileMetadata fileMetadata = new FileMetadata(); fileMetadata.setName(upload.getClientFileName()); fileMetadata.setContentType(upload.getContentType()); fileMetadata.setSize(upload.getSize()); FileContent fileContent = new FileContent(); fileContent.setBytes(upload.getBytes()); fileMetadata.setContent(fileContent); filesModel.add(fileMetadata); // don't display the success notification // FileInputBootstrapFormComponentWrapper.this.success(new // StringResourceModel("successUpload", // FileInputBootstrapFormComponentWrapper.this, // null, new // Model(upload.getClientFileName())).getString()); } } } FileInputBootstrapFormComponentWrapper.this.getModel().setObject((T) filesModel); target.add(fileUploadFeedback); target.add(pendingFiles); } }; add(bootstrapFileInput); /** * due to an upgrade of FormGroup in wicket7/wicket-bootrap-0.10, the * visitor that finds inner FormComponentS, will now find two instead of * one: the FileInputBootstrapFormComponentWrapper and also the * BootstrapFileInputField. This is the RIGHT result, previously in * wicket 6.x it only got the first level of children, hence only one * FormComponent (the FileInputBootstrapFormComponentWrapper). It would * then read the label from FileInputBootstrapFormComponentWrapper and * use it for displaying the label of the FormGroup. In * wicket7/wicket-bootstrap-0.10 this will result in reading the label * of BootstrapFileInputField which is null. So you will notice no * labels for FormGroupS. We fix this by forcing the label of the * underlying fileInput element to the same model as the label used by * FileInputBootstrapFormComponentWrapper */ FormComponent<?> fileInput = (FormComponent<?>) bootstrapFileInput.get("fileInputForm").get("fileInput"); fileInput.setLabel(this.getLabel()); // there are situation when we want to display the upload file component // only to admins if (visibleOnlyToAdmin) { MetaDataRoleAuthorizationStrategy.authorize(bootstrapFileInput, Component.RENDER, SecurityConstants.Roles.ROLE_ADMIN); } // for download the documents when you're already signed in as admin and // want to read only if (disableDeleteButton) { MetaDataRoleAuthorizationStrategy.authorize(bootstrapFileInput, Component.RENDER, MetaDataRoleAuthorizationStrategy.NO_ROLE); } }
From source file:org.devgateway.toolkit.forms.wicket.page.BasePage.java
License:Open Source License
protected NavbarButton<LogoutPage> newLogoutMenu() { // logout menu NavbarButton<LogoutPage> logoutMenu = new NavbarButton<LogoutPage>(LogoutPage.class, new StringResourceModel("navbar.logout", this, null)); logoutMenu.setIconType(GlyphIconType.logout); MetaDataRoleAuthorizationStrategy.authorize(logoutMenu, Component.RENDER, SecurityConstants.Roles.ROLE_USER); return logoutMenu; }