List of usage examples for org.apache.wicket.markup.html WebMarkupContainer setVisible
public final Component setVisible(final boolean visible)
From source file:au.org.theark.admin.web.component.rolePolicy.SearchResultsPanel.java
License:Open Source License
@SuppressWarnings("unchecked") public DataView<ArkRoleModuleFunctionVO> buildDataView( ArkDataProvider<ArkRoleModuleFunctionVO, IAdminService> dataProvider) { DataView<ArkRoleModuleFunctionVO> dataView = new DataView<ArkRoleModuleFunctionVO>( "arkRoleModuleFunctionVoList", dataProvider) { private static final long serialVersionUID = -7977497161071264676L; @Override/* ww w. ja v a 2 s.c o m*/ protected void populateItem(final Item<ArkRoleModuleFunctionVO> item) { final ArkRoleModuleFunctionVO arkRoleModuleFunctionVo = item.getModelObject(); item.setOutputMarkupId(true); item.setOutputMarkupPlaceholderTag(true); WebMarkupContainer rowEditWMC = new WebMarkupContainer("rowEditWMC", item.getModel()); AjaxButton listEditButton = new AjaxButton("listEditButton", new StringResourceModel(au.org.theark.core.Constants.EDIT, this, null)) { private static final long serialVersionUID = 197521505680635043L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { item.setEnabled(true); item.get("arkCreatePermissionImg").setVisible(false); item.get("arkReadPermissionImg").setVisible(false); item.get("arkUpdatePermissionImg").setVisible(false); item.get("arkDeletePermissionImg").setVisible(false); item.addOrReplace(new CheckBox("arkCreatePermission", new PropertyModel(arkRoleModuleFunctionVo, "arkCreatePermission")) .setEnabled(true)); item.addOrReplace(new CheckBox("arkReadPermission", new PropertyModel(arkRoleModuleFunctionVo, "arkReadPermission")).setEnabled(true)); item.addOrReplace(new CheckBox("arkUpdatePermission", new PropertyModel(arkRoleModuleFunctionVo, "arkUpdatePermission")) .setEnabled(true)); item.addOrReplace(new CheckBox("arkDeletePermission", new PropertyModel(arkRoleModuleFunctionVo, "arkDeletePermission")) .setEnabled(true)); item.get("rowSaveWMC").setVisible(true); target.add(item); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { log.error("onError called when listEditButton pressed"); } }; listEditButton.setDefaultFormProcessing(false); rowEditWMC.add(listEditButton); item.add(rowEditWMC); if (arkRoleModuleFunctionVo.getArkRole() != null) { item.add(new Label("arkRole", arkRoleModuleFunctionVo.getArkRole().getName())); } else { item.add(new Label("arkRole", "")); } if (arkRoleModuleFunctionVo.getArkModule() != null) { item.add(new Label("arkModule", arkRoleModuleFunctionVo.getArkModule().getName())); } else { item.add(new Label("arkModule", "")); } if (arkRoleModuleFunctionVo.getArkFunction() != null) { item.add(new Label("arkFunction", arkRoleModuleFunctionVo.getArkFunction().getName())); } else { item.add(new Label("arkFunction", "")); } if (arkRoleModuleFunctionVo.getArkCreatePermission()) { item.addOrReplace( new ContextImage("arkCreatePermissionImg", new Model<String>("images/icons/tick.png"))); } else { item.addOrReplace(new ContextImage("arkCreatePermissionImg", new Model<String>("images/icons/cross.png"))); } if (arkRoleModuleFunctionVo.getArkReadPermission()) { item.addOrReplace( new ContextImage("arkReadPermissionImg", new Model<String>("images/icons/tick.png"))); } else { item.addOrReplace( new ContextImage("arkReadPermissionImg", new Model<String>("images/icons/cross.png"))); } if (arkRoleModuleFunctionVo.getArkUpdatePermission()) { item.addOrReplace( new ContextImage("arkUpdatePermissionImg", new Model<String>("images/icons/tick.png"))); } else { item.addOrReplace(new ContextImage("arkUpdatePermissionImg", new Model<String>("images/icons/cross.png"))); } if (arkRoleModuleFunctionVo.getArkDeletePermission()) { item.addOrReplace( new ContextImage("arkDeletePermissionImg", new Model<String>("images/icons/tick.png"))); } else { item.addOrReplace(new ContextImage("arkDeletePermissionImg", new Model<String>("images/icons/cross.png"))); } item.addOrReplace(new CheckBox("arkCreatePermission", new PropertyModel(arkRoleModuleFunctionVo, "arkCreatePermission")).setVisible(false)); item.addOrReplace(new CheckBox("arkReadPermission", new PropertyModel(arkRoleModuleFunctionVo, "arkReadPermission")).setVisible(false)); item.addOrReplace(new CheckBox("arkUpdatePermission", new PropertyModel(arkRoleModuleFunctionVo, "arkUpdatePermission")).setVisible(false)); item.addOrReplace(new CheckBox("arkDeletePermission", new PropertyModel(arkRoleModuleFunctionVo, "arkDeletePermission")).setVisible(false)); WebMarkupContainer rowSaveWMC = new WebMarkupContainer("rowSaveWMC", item.getModel()); AjaxButton listSaveButton = new AjaxButton("listSaveButton", new StringResourceModel(au.org.theark.core.Constants.SAVE, this, null)) { private static final long serialVersionUID = -7382768898426488999L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { onSave(target, arkRoleModuleFunctionVo); target.add(SearchResultsPanel.this); target.add(feedbackPanel); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { log.error("onError called when listSaveButton pressed"); } }; rowSaveWMC.add(listSaveButton); rowSaveWMC.setVisible(false); item.add(rowSaveWMC); item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1938679383897533820L; @Override public String getObject() { return (item.getIndex() % 2 == 1) ? "even" : "odd"; } })); } }; return dataView; }
From source file:au.org.theark.core.web.StudyHelper.java
License:Open Source License
public void setStudyLogo(Study study, AjaxRequestTarget target, WebMarkupContainer studyNameMarkup, WebMarkupContainer studyLogoMarkup) { // Set the study logo Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); if (sessionStudyId != null && study.getStudyLogoBlob() != null) { setStudyLogoImage(study, "studyLogoImage", studyLogoMarkup); studyNameMarkup.setVisible(false); studyLogoMarkup.setVisible(true); } else {/*from w w w .j av a2 s . co m*/ // Only show study name, no logo studyNameLabel = new Label("studyNameLabel", new Model<String>(study.getName())); studyNameMarkup.replace(studyNameLabel); studyNameMarkup.setVisible(true); studyLogoMarkup.setVisible(false); } target.add(studyNameMarkup); target.add(studyLogoMarkup); }
From source file:au.org.theark.lims.web.component.biospecimenupload.BiospecimenUploadStep2.java
License:Open Source License
@Override public void onStepInNext(AbstractWizardForm<?> form, AjaxRequestTarget target) { try {//from www . j av a2s .co m InputStream inputStream = containerForm.getModelObject().getFileUpload().getInputStream(); FileUpload fileUpload = containerForm.getModelObject().getFileUpload(); String uploadType = containerForm.getModelObject().getUploadType(); log.info("so what is the upload type =" + uploadType); String filename = containerForm.getModelObject().getFileUpload().getClientFileName(); String fileFormat = filename.substring(filename.lastIndexOf('.') + 1).toUpperCase(); char delimChar = containerForm.getModelObject().getUpload().getDelimiterType().getDelimiterCharacter(); // Only allow csv, txt or xls if (!(fileFormat.equalsIgnoreCase("CSV") || fileFormat.equalsIgnoreCase("TXT") || fileFormat.equalsIgnoreCase("XLS"))) { throw new FileFormatException(); } BioCollectionSpecimenUploadValidator bioCollectionSpecimenUploadValidator = new BioCollectionSpecimenUploadValidator( containerForm.getModelObject().getUpload().getStudy(), iArkCommonService, iLimsService, iInventoryService); if (uploadType.equalsIgnoreCase(Constants.UPLOAD_TYPE_FOR_BIOCOLLECTION)) { validationMessages = bioCollectionSpecimenUploadValidator.validateLimsFileFormatAndHeaderDetail( containerForm.getModelObject(), au.org.theark.core.Constants.BIOCOLLECTION_TEMPLATE_HEADER); } else if (uploadType.equalsIgnoreCase(Constants.UPLOAD_TYPE_FOR_BIOSPECIMEN_INVENTARY)) { validationMessages = bioCollectionSpecimenUploadValidator.validateLimsFileFormatAndHeaderDetail( containerForm.getModelObject(), au.org.theark.core.Constants.BIOSPECIMEN_INVENTORY_TEMPLATE_HEADER); } else if (uploadType.equalsIgnoreCase(Constants.UPLOAD_TYPE_FOR_BIOSPECIMEN)) { validationMessages = bioCollectionSpecimenUploadValidator.validateLimsFileFormatAndHeaderDetail( containerForm.getModelObject(), au.org.theark.core.Constants.BIOSPECIMEN_TEMPLATE_HEADER); } containerForm.getModelObject().setValidationMessages(validationMessages); validationMessage = containerForm.getModelObject().getValidationMessagesAsString(); addOrReplace(new MultiLineLabel("multiLineLabel", validationMessage)); ArkExcelWorkSheetAsGrid arkExcelWorkSheetAsGrid = new ArkExcelWorkSheetAsGrid("gridView", inputStream, fileFormat, delimChar, fileUpload, iArkCommonService .getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue()); arkExcelWorkSheetAsGrid.setOutputMarkupId(true); WebMarkupContainer wizardDataGridKeyContainer = new WebMarkupContainer("wizardDataGridKeyContainer"); wizardDataGridKeyContainer.setVisible(false); wizardDataGridKeyContainer.setOutputMarkupId(true); form.setArkExcelWorkSheetAsGrid(arkExcelWorkSheetAsGrid); form.getWizardPanelFormContainer().addOrReplace(arkExcelWorkSheetAsGrid); form.setArkExcelWorkSheetAsGrid(arkExcelWorkSheetAsGrid); form.getWizardPanelFormContainer().addOrReplace(wizardDataGridKeyContainer); target.add(form.getWizardPanelFormContainer()); containerForm.getModelObject().setValidationMessages(validationMessages); validationMessage = containerForm.getModelObject().getValidationMessagesAsString(); addOrReplace(new MultiLineLabel("multiLineLabel", validationMessage)); if (validationMessage != null && validationMessage.length() > 0) { this.containerForm.getModelObject().getUpload() .setUploadStatus(iArkCommonService.getUploadStatusFor( au.org.theark.lims.web.Constants.UPLOAD_STATUS_OF_ERROR_IN_FILE_VALIDATION)); this.containerForm.getModelObject().getUpload().setFilename(filename);//have to reset this because the container has the file name...luckily it never changes iArkCommonService.updateUpload(this.containerForm.getModelObject().getUpload()); form.getNextButton().setEnabled(false); target.add(form.getWizardButtonContainer()); downloadValMsgButton = new ArkDownloadAjaxButton("downloadValMsg", "ValidationMessage", validationMessage, "txt") { private static final long serialVersionUID = 1L; @Override protected void onError(AjaxRequestTarget target, Form<?> form) { this.error("Unexpected Error: Download request could not be processed"); } }; addOrReplace(downloadValMsgButton); target.add(downloadValMsgButton); } } catch (IOException e) { validationMessage = "Error attempting to display the file. Please check the file and try again."; addOrReplace(new MultiLineLabel("multiLineLabel", validationMessage)); form.getNextButton().setEnabled(false); target.add(form.getWizardButtonContainer()); } catch (FileFormatException ffe) { validationMessage = "Error uploading file. You can only upload files of type: CSV (comma separated values), TXT (text), or XLS (Microsoft Excel file)"; addOrReplace(new MultiLineLabel("multiLineLabel", validationMessage)); form.getNextButton().setEnabled(false); target.add(form.getWizardButtonContainer()); } }
From source file:au.org.theark.lims.web.component.bioupload.BioUploadStep2.java
License:Open Source License
@Override public void onStepInNext(AbstractWizardForm<?> form, AjaxRequestTarget target) { try {/*from w w w . j a v a2 s . co m*/ FileUpload fileUpload = containerForm.getModelObject().getFileUpload(); InputStream inputStream = fileUpload.getInputStream();//TODO : should something this big be thrown around model object in wicket? String filename = fileUpload.getClientFileName(); String fileFormat = filename.substring(filename.lastIndexOf('.') + 1).toUpperCase(); char delimChar = containerForm.getModelObject().getUpload().getDelimiterType().getDelimiterCharacter(); // Only allow csv, txt or xls TODO : if we are hardcoding things like this, why do we fetch file formats from db and store as a fk reference? if (!(fileFormat.equalsIgnoreCase("CSV") || fileFormat.equalsIgnoreCase("TXT") || fileFormat.equalsIgnoreCase("XLS"))) { throw new FileFormatException(); } //TODO: remove hardcode if (containerForm.getModelObject().getUpload().getUploadType().getName() .equalsIgnoreCase("Biospecimen Custom Data")) { BioCustomFieldUploadValidator subjectUploadValidator = new BioCustomFieldUploadValidator( iArkCommonService, iLimsService); validationMessages = subjectUploadValidator .validateBiospecimenCustomFieldFileFormat(containerForm.getModelObject()); } else if (containerForm.getModelObject().getUpload().getUploadType().getName() .equalsIgnoreCase("Biocollection Custom Data")) { //TODO : custom field validation BioCustomFieldUploadValidator customFieldUploadValidator = new BioCustomFieldUploadValidator( iArkCommonService, iLimsService); validationMessages = customFieldUploadValidator .validateBiocollectionCustomFieldFileFormat(containerForm.getModelObject()); } else { //TODO : Throw error back to user } ArkExcelWorkSheetAsGrid arkExcelWorkSheetAsGrid = new ArkExcelWorkSheetAsGrid("gridView", inputStream, fileFormat, delimChar, fileUpload, iArkCommonService .getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue(), containerForm.getModelObject().getUpload().getUploadType()); arkExcelWorkSheetAsGrid.setOutputMarkupId(true); WebMarkupContainer wizardDataGridKeyContainer = new WebMarkupContainer("wizardDataGridKeyContainer"); wizardDataGridKeyContainer.setVisible(false); wizardDataGridKeyContainer.setOutputMarkupId(true); form.setArkExcelWorkSheetAsGrid(arkExcelWorkSheetAsGrid); form.getWizardPanelFormContainer().addOrReplace(arkExcelWorkSheetAsGrid); form.setArkExcelWorkSheetAsGrid(arkExcelWorkSheetAsGrid); form.getWizardPanelFormContainer().addOrReplace(wizardDataGridKeyContainer); target.add(form.getWizardPanelFormContainer()); containerForm.getModelObject().setValidationMessages(validationMessages); validationMessage = containerForm.getModelObject().getValidationMessagesAsString(); addOrReplace(new MultiLineLabel("multiLineLabel", validationMessage)); if (validationMessage != null && validationMessage.length() > 0) { log.warn("validation = " + validationMessage); form.getNextButton().setEnabled(false); target.add(form.getWizardButtonContainer()); downloadValMsgButton = new ArkDownloadAjaxButton("downloadValMsg", "ValidationMessage", validationMessage, "txt") { private static final long serialVersionUID = 1L; @Override protected void onError(AjaxRequestTarget target, Form<?> form) { this.error("Unexpected Error: Download request could not be processed"); } }; addOrReplace(downloadValMsgButton); target.add(downloadValMsgButton); } } catch (IOException e) { validationMessage = "Error attempting to display the file. Please check the file and try again."; addOrReplace(new MultiLineLabel("multiLineLabel", validationMessage)); form.getNextButton().setEnabled(false); target.add(form.getWizardButtonContainer()); } catch (FileFormatException ffe) { validationMessage = "Error uploading file. You can only upload files of type: CSV (comma separated values), TXT (text), or XLS (Microsoft Excel file)"; addOrReplace(new MultiLineLabel("multiLineLabel", validationMessage)); form.getNextButton().setEnabled(false); target.add(form.getWizardButtonContainer()); } //TODO : finally? close io? }
From source file:au.org.theark.study.web.component.consent.form.FormHelper.java
License:Open Source License
public void updateStudyCompStatusDates(AjaxRequestTarget target, String statusName, WebMarkupContainer wmcPlain, WebMarkupContainer wmcRequested, WebMarkupContainer wmcRecieved, WebMarkupContainer wmcCompleted) { if ((statusName.equalsIgnoreCase(Constants.STUDY_STATUS_RECEIVED))) { wmcRecieved.setVisible(true); wmcPlain.setVisible(false);//from ww w. j a v a 2 s. com wmcRequested.setVisible(false); wmcCompleted.setVisible(false); target.add(wmcPlain); target.add(wmcRecieved); target.add(wmcRequested); target.add(wmcCompleted); } else if ((statusName.equalsIgnoreCase(Constants.STUDY_STATUS_REQUESTED))) { wmcRequested.setVisible(true); wmcPlain.setVisible(false); wmcRecieved.setVisible(false); wmcCompleted.setVisible(false); target.add(wmcRecieved); target.add(wmcRequested); target.add(wmcPlain); target.add(wmcCompleted); } else if ((statusName.equalsIgnoreCase(Constants.STUDY_STATUS_COMPLETED))) { wmcCompleted.setVisible(true); wmcPlain.setVisible(false); wmcRecieved.setVisible(false); wmcRequested.setVisible(false); target.add(wmcCompleted); target.add(wmcRecieved); target.add(wmcRequested); target.add(wmcPlain); } else { setDatePickerDefaultMarkup(target, wmcPlain, wmcRequested, wmcRecieved, wmcCompleted); } }
From source file:au.org.theark.study.web.component.consent.form.FormHelper.java
License:Open Source License
public void setDatePickerDefaultMarkup(AjaxRequestTarget target, WebMarkupContainer wmcPlain, WebMarkupContainer wmcRequested, WebMarkupContainer wmcRecieved, WebMarkupContainer wmcCompleted) { wmcPlain.setVisible(true); wmcRecieved.setVisible(false);/*from w ww . ja v a 2 s . co m*/ wmcRequested.setVisible(false); wmcCompleted.setVisible(false); target.add(wmcCompleted); target.add(wmcRecieved); target.add(wmcRequested); target.add(wmcPlain); }
From source file:au.org.theark.study.web.component.subjectUpload.SubjectUploadStep2.java
License:Open Source License
@Override public void onStepInNext(AbstractWizardForm<?> form, AjaxRequestTarget target) { try {/*from ww w . j a va 2 s . co m*/ FileUpload fileUpload = containerForm.getModelObject().getFileUpload(); InputStream inputStream = fileUpload.getInputStream();//TODO : should something this big be thrown around model object in wicket? String filename = fileUpload.getClientFileName(); String fileFormat = filename.substring(filename.lastIndexOf('.') + 1).toUpperCase(); char delimChar = containerForm.getModelObject().getUpload().getDelimiterType().getDelimiterCharacter(); // Only allow csv, txt, xls Or ped TODO : if we are hardcoding things like this, why do we fetch file formats from db and store as a fk reference? if (!(fileFormat.equalsIgnoreCase("CSV") || fileFormat.equalsIgnoreCase("TXT") || fileFormat.equalsIgnoreCase("XLS") || fileFormat.equalsIgnoreCase("PED"))) { throw new FileFormatException(); } //Create Upload iArkCommonService.createUpload(containerForm.getModelObject().getUpload()); if (containerForm.getModelObject().getUpload().getUploadType().getName() .equalsIgnoreCase(Constants.SUBJECT_DEMOGRAPHIC_DATA)) { SubjectUploadValidator subjectUploadValidator = new SubjectUploadValidator(iArkCommonService); validationMessages = subjectUploadValidator .validateSubjectFileFormat(containerForm.getModelObject()); } else if (containerForm.getModelObject().getUpload().getUploadType().getName() .equalsIgnoreCase(Constants.STUDY_SPECIFIC_CUSTOM_DATA)) { //TODO : custom field validation CustomFieldUploadValidator customFieldUploadValidator = new CustomFieldUploadValidator( iArkCommonService); validationMessages = customFieldUploadValidator .validateCustomFieldFileFormat(containerForm.getModelObject()); } else if (containerForm.getModelObject().getUpload().getUploadType().getName() .equalsIgnoreCase(Constants.SUBJECT_CONSENT_DATA)) { SubjectConsentUploadValidator subjectConsentUploadValidator = new SubjectConsentUploadValidator(); validationMessages = subjectConsentUploadValidator .validateSubjectConsentFileFormat(containerForm.getModelObject()); } else if (containerForm.getModelObject().getUpload().getUploadType().getName() .equalsIgnoreCase(Constants.PEDIGREE_DATA)) { PedigreeUploadValidator subjectConsentUploadValidator = new PedigreeUploadValidator(); validationMessages = subjectConsentUploadValidator .validatePedigreeFileFormat(containerForm.getModelObject()); } else if (containerForm.getModelObject().getUpload().getUploadType().getName() .equalsIgnoreCase(Constants.SUBJECT_ATTACHMENT_DATA)) { SubjectAttachmentValidator subjectAttachmentValidator = new SubjectAttachmentValidator(); validationMessages = subjectAttachmentValidator .validateSubjectAttachmentFileFormat(containerForm.getModelObject()); } else { //TODO : Throw error back to user } ArkExcelWorkSheetAsGrid arkExcelWorkSheetAsGrid = null; if (Constants.PEDIGREE_DATA .equalsIgnoreCase(containerForm.getModelObject().getUpload().getUploadType().getName())) { arkExcelWorkSheetAsGrid = new ArkExcelWorkSheetAsGrid("gridView", inputStream, fileFormat, delimChar, fileUpload, iArkCommonService .getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue(), containerForm.getModelObject().getUpload().getUploadType(), false); } else { arkExcelWorkSheetAsGrid = new ArkExcelWorkSheetAsGrid("gridView", inputStream, fileFormat, delimChar, fileUpload, iArkCommonService .getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue(), containerForm.getModelObject().getUpload().getUploadType()); } arkExcelWorkSheetAsGrid.setOutputMarkupId(true); WebMarkupContainer wizardDataGridKeyContainer = new WebMarkupContainer("wizardDataGridKeyContainer"); wizardDataGridKeyContainer.setVisible(false); wizardDataGridKeyContainer.setOutputMarkupId(true); form.setArkExcelWorkSheetAsGrid(arkExcelWorkSheetAsGrid); form.getWizardPanelFormContainer().addOrReplace(arkExcelWorkSheetAsGrid); form.setArkExcelWorkSheetAsGrid(arkExcelWorkSheetAsGrid); form.getWizardPanelFormContainer().addOrReplace(wizardDataGridKeyContainer); target.add(form.getWizardPanelFormContainer()); containerForm.getModelObject().setValidationMessages(validationMessages); validationMessage = containerForm.getModelObject().getValidationMessagesAsString(); addOrReplace(new MultiLineLabel("multiLineLabel", validationMessage)); if (validationMessage != null && validationMessage.length() > 0) { this.containerForm.getModelObject().getUpload() .setUploadStatus(iArkCommonService.getUploadStatusFor( au.org.theark.study.web.Constants.UPLOAD_STATUS_OF_ERROR_IN_FILE_VALIDATION)); this.containerForm.getModelObject().getUpload().setFilename(filename);//have to reset this because the container has the file name...luckily it never changes iArkCommonService.updateUpload(this.containerForm.getModelObject().getUpload()); log.warn("validation = " + validationMessage); form.getNextButton().setEnabled(false); target.add(form.getWizardButtonContainer()); downloadValMsgButton = new ArkDownloadAjaxButton("downloadValMsg", "ValidationMessage", validationMessage, "txt") { private static final long serialVersionUID = 1L; @Override protected void onError(AjaxRequestTarget target, Form<?> form) { this.error("Unexpected Error: Download request could not be processed"); } }; addOrReplace(downloadValMsgButton); target.add(downloadValMsgButton); } /*else{ this.containerForm.getModelObject().getUpload().setUploadStatus(iArkCommonService.getUploadStatusFor(au.org.theark.study.web.Constants.UPLOAD_STATUS_OF_VALIDATED)); this.containerForm.getModelObject().getUpload().setFilename(filename);//have to reset this because the container has the file name...luckily it never changes iArkCommonService.updateUpload(this.containerForm.getModelObject().getUpload()); }*/ } catch (IOException e) { validationMessage = "Error attempting to display the file. Please check the file and try again."; addOrReplace(new MultiLineLabel("multiLineLabel", validationMessage)); form.getNextButton().setEnabled(false); target.add(form.getWizardButtonContainer()); } catch (FileFormatException ffe) { validationMessage = "Error uploading file. You can only upload files of type: CSV (comma separated values), TXT (text), or XLS (Microsoft Excel file)"; addOrReplace(new MultiLineLabel("multiLineLabel", validationMessage)); form.getNextButton().setEnabled(false); target.add(form.getWizardButtonContainer()); } catch (Exception e) { log.error("unexpected exception, not shown to user...INVESTIGATE :\n", e); validationMessage = "Error attempting to validate the file. Please contact your system administrator."; addOrReplace(new MultiLineLabel("multiLineLabel", validationMessage)); form.getNextButton().setEnabled(false); target.add(form.getWizardButtonContainer()); } //TODO : finally? close io? }
From source file:by.grodno.ss.rentacar.webapp.page.admin.panel.UserEditPanel.java
@Override public void onInitialize() { super.onInitialize(); UserEditPanel.this.setOutputMarkupId(true); Form<UserProfile> form = new Form<UserProfile>("form", new CompoundPropertyModel<UserProfile>(userProfile)); TextField<String> created = new TextField<String>("created"); created.setEnabled(false);//from w w w. j a v a 2 s . co m form.add(created); TextField<String> email = new TextField<String>("email", new PropertyModel<>(userCredentials, "email")); email.setRequired(true); email.add(StringValidator.maximumLength(100)); email.add(StringValidator.minimumLength(3)); email.add(EmailAddressValidator.getInstance()); form.add(email); DropDownChoice<UserRole> roleDropDown = new DropDownChoice<>("role", new PropertyModel<>(userCredentials, "role"), Arrays.asList(UserRole.values()), UserRoleChoiceRenderer.INSTANCE); roleDropDown.setRequired(true); form.add(roleDropDown); TextField<String> firstName = new TextField<String>("firstName"); firstName.setRequired(true); firstName.add(StringValidator.maximumLength(100)); firstName.add(StringValidator.minimumLength(2)); firstName.add(new PatternValidator("[A-Za-z]+")); form.add(firstName); TextField<String> lastName = new TextField<String>("lastName"); lastName.setRequired(true); lastName.add(StringValidator.maximumLength(100)); lastName.add(StringValidator.minimumLength(2)); lastName.add(new PatternValidator("[A-Za-z]+")); form.add(lastName); TextField<String> phone = new TextField<String>("phoneNumber"); phone.setRequired(true); phone.add(StringValidator.maximumLength(100)); phone.add(StringValidator.minimumLength(2)); phone.add(new PatternValidator("[0-9+()-]+")); form.add(phone); TextField<String> licNumber = new TextField<String>("licenseNumber"); licNumber.add(StringValidator.maximumLength(100)); licNumber.add(StringValidator.minimumLength(2)); licNumber.add(new PatternValidator("[A-Za-z0-9]+")); form.add(licNumber); DateTextFieldConfig config = new DateTextFieldConfig(); config.withLanguage(AuthorizedSession.get().getLocale().getLanguage()); config.withFormat("dd.MM.yyyy"); DateTextField dateBirth = new DateTextField("birthDay", config); form.add(dateBirth); TextField<String> address = new TextField<String>("address"); address.add(StringValidator.maximumLength(100)); address.add(StringValidator.minimumLength(2)); address.add(new PatternValidator("[A-Za-z0-9 /-]+")); form.add(address); TextField<String> city = new TextField<String>("city"); city.add(StringValidator.maximumLength(100)); city.add(StringValidator.minimumLength(2)); city.add(new PatternValidator("[A-Za-z0-9]+")); form.add(city); TextField<String> region = new TextField<String>("region"); region.add(StringValidator.maximumLength(100)); region.add(StringValidator.minimumLength(2)); region.add(new PatternValidator("[A-Za-z0-9]+")); form.add(region); TextField<String> zip = new TextField<String>("zipCode"); zip.add(StringValidator.maximumLength(20)); zip.add(StringValidator.minimumLength(2)); zip.add(new PatternValidator("[0-9]+")); form.add(zip); WebMarkupContainer passTable = new WebMarkupContainer("pass-table"); passTable.setOutputMarkupId(true); WebMarkupContainer trPass = new WebMarkupContainer("pass"); WebMarkupContainer trCpass = new WebMarkupContainer("cpass"); if (userProfile.getId() == null) { trPass.setVisible(true); trCpass.setVisible(true); } else { trPass.setVisible(false); trCpass.setVisible(false); } trPass.setOutputMarkupId(true); trCpass.setOutputMarkupId(true); PasswordTextField password = new PasswordTextField("password", new PropertyModel<>(userCredentials, "password")); trPass.add(password); PasswordTextField cpassword = new PasswordTextField("cpassword", Model.of("")); trCpass.add(cpassword); passTable.add(trPass); passTable.add(trCpass); form.add(passTable); form.add(new EqualPasswordInputValidator(password, cpassword)); AjaxLink<Void> changePass = new AjaxLink<Void>("change-password") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { if (!trPass.isVisible()) { trPass.setVisible(true); trCpass.setVisible(true); passTable.add(trPass); passTable.add(trCpass); } else { trPass.setVisible(false); trCpass.setVisible(false); } if (target != null) { target.add(passTable); } } }; if (userProfile.getId() == null) { changePass.setVisible(false); } form.add(changePass); form.add(new SubmitLink("save") { private static final long serialVersionUID = 1L; @Override public void onSubmit() { if (userProfile.getId() == null) { userService.register(userProfile, userCredentials); } else { userService.update(userProfile); userService.update(userCredentials); } info("User was saved"); } }); boolean a = (AuthorizedSession.get().isSignedIn() && AuthorizedSession.get().getLoggedUser().getRole().equals(UserRole.ADMIN)); form.setEnabled(a); add(form); add(new AjaxLink<Void>("back") { private static final long serialVersionUID = 1L; public void onClick(AjaxRequestTarget target) { Component newPanel = new UserListPanel(UserEditPanel.this.getId(), filter); UserEditPanel.this.replaceWith(newPanel); if (target != null) { target.add(newPanel); } } }); }
From source file:by.grodno.ss.rentacar.webapp.page.MyBooking.ProfileEditPanel.java
@Override public void onInitialize() { super.onInitialize(); final NotificationPanel feedback = new NotificationPanel("feedbackpanel"); add(feedback);//w w w .ja v a 2 s . co m Form<UserProfile> form = new Form<UserProfile>("form", new CompoundPropertyModel<UserProfile>(userProfile)); TextField<String> firstName = new TextField<String>("firstName"); firstName.setRequired(true); firstName.add(StringValidator.maximumLength(100)); firstName.add(StringValidator.minimumLength(2)); firstName.add(new PatternValidator("[A-Za-z]+")); form.add(firstName); TextField<String> lastName = new TextField<String>("lastName"); lastName.setRequired(true); lastName.add(StringValidator.maximumLength(100)); lastName.add(StringValidator.minimumLength(2)); lastName.add(new PatternValidator("[A-Za-z]+")); form.add(lastName); TextField<String> phone = new TextField<String>("phoneNumber"); phone.setRequired(true); phone.add(StringValidator.maximumLength(100)); phone.add(StringValidator.minimumLength(2)); phone.add(new PatternValidator("[0-9+()-]+")); form.add(phone); TextField<String> licNumber = new TextField<String>("licenseNumber"); licNumber.add(StringValidator.maximumLength(100)); licNumber.add(StringValidator.minimumLength(2)); licNumber.add(new PatternValidator("[A-Za-z0-9]+")); form.add(licNumber); DateTextFieldConfig config = new DateTextFieldConfig(); config.withLanguage(AuthorizedSession.get().getLocale().getLanguage()); config.withFormat("dd.MM.yyyy"); DateTextField dateBirth = new DateTextField("birthDay", config); form.add(dateBirth); TextField<String> address = new TextField<String>("address"); address.add(StringValidator.maximumLength(100)); address.add(StringValidator.minimumLength(2)); address.add(new PatternValidator("[A-Za-z0-9 /-]+")); form.add(address); TextField<String> city = new TextField<String>("city"); city.add(StringValidator.maximumLength(100)); city.add(StringValidator.minimumLength(2)); city.add(new PatternValidator("[A-Za-z0-9]+")); form.add(city); TextField<String> region = new TextField<String>("region"); region.add(StringValidator.maximumLength(100)); region.add(StringValidator.minimumLength(2)); region.add(new PatternValidator("[A-Za-z0-9]+")); form.add(region); TextField<String> zip = new TextField<String>("zipCode"); zip.add(StringValidator.maximumLength(20)); zip.add(StringValidator.minimumLength(2)); zip.add(new PatternValidator("[0-9]+")); form.add(zip); Label email = new Label("email", new PropertyModel<>(userCredentials, "email")); form.add(email); WebMarkupContainer passTable = new WebMarkupContainer("pass-table"); passTable.setOutputMarkupId(true); WebMarkupContainer trPass = new WebMarkupContainer("pass"); WebMarkupContainer trCpass = new WebMarkupContainer("cpass"); if (userProfile.getId() == null) { trPass.setVisible(true); trCpass.setVisible(true); } else { trPass.setVisible(false); trCpass.setVisible(false); } trPass.setOutputMarkupId(true); trCpass.setOutputMarkupId(true); PasswordTextField password = new PasswordTextField("password", new PropertyModel<>(userCredentials, "password")); trPass.add(password); PasswordTextField cpassword = new PasswordTextField("cpassword", Model.of("")); trCpass.add(cpassword); passTable.add(trPass); passTable.add(trCpass); form.add(passTable); form.add(new EqualPasswordInputValidator(password, cpassword)); AjaxLink<Void> changePass = new AjaxLink<Void>("change-password") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { if (!trPass.isVisible()) { trPass.setVisible(true); trCpass.setVisible(true); passTable.add(trPass); passTable.add(trCpass); } else { trPass.setVisible(false); trCpass.setVisible(false); } if (target != null) { target.add(passTable); } } }; if (userProfile.getId() == null) { changePass.setVisible(false); } form.add(changePass); form.add(new SubmitLink("save") { private static final long serialVersionUID = 1L; @Override public void onSubmit() { if (userProfile.getId() == null) { error("saving error"); } else { userService.update(userProfile); userService.update(userCredentials); } info("User was saved"); } }); add(form); add(new Link<Void>("back") { private static final long serialVersionUID = 1L; @Override public void onClick() { setResponsePage(new MyBookingPage()); } }); }
From source file:ch.tkuhn.nanobrowser.TriplePanel.java
License:Open Source License
public TriplePanel(String id, Triple<?, ?> triple, int settings) { super(id);/*from w ww . java 2s . c om*/ this.settings = settings; if (isFlagSet(SHOW_SUBJECT)) { add(triple.getSubject().createGUIItem("subject")); } else { hide("subject"); } if (isFlagSet(SHOW_PREDICATE)) { if (isFlagSet(START_WITH_PREDICATE)) { add(triple.getPredicate().createGUIItem("predicatefirst", ThingElement.PREDICATEFIRST_ITEM)); hide("predicate"); } else { add(triple.getPredicate().createGUIItem("predicate")); hide("predicatefirst"); } } else { hide("predicatefirst"); hide("predicate"); } if (isFlagSet(SHOW_OBJECT)) { Object obj = triple.getObject(); if (obj instanceof ThingElement) { add(((ThingElement) obj).createGUIItem("object")); } else { add(new Label("object", "\"" + obj.toString() + "\"")); } } else { hide("object"); } if (isFlagSet(SHOW_FULLSTOP)) { add(new Label("end", ".")); } else { hide("end"); } WebMarkupContainer ref = new WebMarkupContainer("reference"); if (triple.getNanopub() == null) { ref.setVisible(false); ref.add(new Label("nanopub")); } else { ref.add(new NanopubItem("nanopub", triple.getNanopub(), ThingElement.TINY_GUI_ITEM)); } add(ref); }