List of usage examples for org.apache.wicket.ajax AjaxRequestTarget add
void add(Component... components);
From source file:au.org.theark.study.web.component.subjectcustomdata.SubjectCustomDataEditorPanel.java
License:Open Source License
public SubjectCustomDataEditorPanel initialisePanel() { customDataEditorForm = new CustomDataEditorForm("customDataEditorForm", cpModel, feedbackPanel) .initialiseForm();//from ww w . j av a 2 s . c om Collection<CustomFieldCategory> customFieldCategoryCollection = getAvailableAllCategoryListInStudyByCustomFieldType(); List<CustomFieldCategory> customFieldCatLst = CustomFieldCategoryOrderingHelper.getInstance() .orderHierarchicalyCustomFieldCategories((List<CustomFieldCategory>) customFieldCategoryCollection); ChoiceRenderer customfieldCategoryRenderer = new ChoiceRenderer(Constants.CUSTOMFIELDCATEGORY_NAME, Constants.CUSTOMFIELDCATEGORY_ID) { @Override public Object getDisplayValue(Object object) { CustomFieldCategory cuscat = (CustomFieldCategory) object; return CustomFieldCategoryOrderingHelper.getInstance().preTextDecider(cuscat) + super.getDisplayValue(object); } }; customeFieldCategoryDdc = new DropDownChoice<CustomFieldCategory>( Constants.FIELDVO_CUSTOMFIELD_CUSTOEMFIELDCATEGORY, customFieldCatLst, customfieldCategoryRenderer); customeFieldCategoryDdc.setOutputMarkupId(true); customeFieldCategoryDdc.setNullValid(true); customeFieldCategoryDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { customDataEditorForm.getDataViewWMC().remove(dataViewPanel); dataViewPanel = new SubjectCustomDataDataViewPanel("dataViewPanel", cpModel).initialisePanel(null, customeFieldCategoryDdc.getModelObject()); customDataEditorForm.getDataViewWMC().add(dataViewPanel); target.add(dataViewPanel); target.add(customDataEditorForm); } }); //dataViewPanel = new SubjectCustomDataDataViewPanel("dataViewPanel", cpModel).initialisePanel(null); //initialise dataViewPanel = new SubjectCustomDataDataViewPanel("dataViewPanel", cpModel).initialisePanel(null, customeFieldCategoryDdc.getModelObject()); AjaxPagingNavigator pageNavigator = new AjaxPagingNavigator("navigator", dataViewPanel.getDataView()) { @Override protected void onAjaxEvent(AjaxRequestTarget target) { target.add(customDataEditorForm.getDataViewWMC()); target.add(this); } }; pageNavigator.setVisible(false); customDataEditorForm.add(customeFieldCategoryDdc); customDataEditorForm.getDataViewWMC().add(dataViewPanel); warnSaveLabel = new Label("warnSaveLabel", new ResourceModel("warnSaveLabel")); warnSaveLabel.setVisible(ArkPermissionHelper.isActionPermitted(Constants.NEW)); add(customDataEditorForm); add(pageNavigator); add(warnSaveLabel); return this; }
From source file:au.org.theark.study.web.component.subjectUpload.SubjectUploadStep1.java
License:Open Source License
@SuppressWarnings({ "unchecked" }) private void initialiseDropDownChoices() { final java.util.Collection<DelimiterType> delimiterTypeCollection = iArkCommonService.getDelimiterTypes(); ChoiceRenderer delimiterTypeRenderer = new ChoiceRenderer( au.org.theark.study.web.Constants.DELIMITER_TYPE_NAME, au.org.theark.study.web.Constants.DELIMITER_TYPE_ID); delimiterTypeDdc = new DropDownChoice<DelimiterType>( au.org.theark.study.web.Constants.UPLOADVO_UPLOAD_DELIMITER_TYPE, (List) delimiterTypeCollection, delimiterTypeRenderer);/*from w w w.ja va 2 s . c o m*/ containerForm.getModelObject().getUpload() .setDelimiterType(iArkCommonService.getDelimiterType(new Long(1))); java.util.Collection<UploadType> uploadTypeCollection = iArkCommonService .getUploadTypesForSubject(containerForm.getModelObject().getStudy()); ChoiceRenderer uploadTypeRenderer = new ChoiceRenderer(au.org.theark.study.web.Constants.UPLOAD_TYPE_NAME, au.org.theark.study.web.Constants.UPLOAD_TYPE_ID); uploadTypeDdc = new DropDownChoice<UploadType>( au.org.theark.study.web.Constants.UPLOADVO_UPLOAD_UPLOAD_TYPE, (List) uploadTypeCollection, uploadTypeRenderer); uploadTypeDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { UploadType uploadType = uploadTypeDdc.getModelObject(); //TODO : Why is this delimiter logic in here? on change of uploadtype??? DelimiterType tabtype = null; DelimiterType commatype = null; for (DelimiterType type : delimiterTypeCollection) { if ("TAB".equalsIgnoreCase(type.getName())) { tabtype = type; } else if ("COMMA".equalsIgnoreCase(type.getName())) { commatype = type; } } if (uploadType != null && au.org.theark.study.web.Constants.PEDIGREE_DATA.equals(uploadType.getName())) { delimiterTypeDdc.setModelObject(tabtype); delimiterTypeDdc.setEnabled(false); } else { delimiterTypeDdc.setModelObject(commatype); delimiterTypeDdc.setEnabled(true); } target.add(delimiterTypeDdc); } }); containerForm.getModelObject().getUpload().setUploadType(iArkCommonService.getDefaultUploadType()); }
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 {// ww w . ja v a2 s . com 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:au.org.theark.study.web.component.subjectUpload.SubjectUploadStep3.java
License:Open Source License
private void initialiseDetailForm() { setValidationMessage(containerForm.getModelObject().getValidationMessagesAsString()); addOrReplace(new MultiLineLabel("multiLineLabel", getValidationMessage())); add(downloadValMsgButton);/* w ww .j a v a 2 s . c o m*/ updateExistingDataContainer = new WebMarkupContainer("updateExistingDataContainer"); updateExistingDataContainer.setOutputMarkupId(true); updateChkBox = new CheckBox("updateChkBox"); updateChkBox.add(new AjaxFormComponentUpdatingBehavior("onChange") { private static final long serialVersionUID = -4514605801401294450L; @Override protected void onUpdate(AjaxRequestTarget target) { if (containerForm.getModelObject().getUpdateChkBox()) { wizardForm.getNextButton().setEnabled(true); } else { wizardForm.getNextButton().setEnabled(false); } target.add(wizardForm.getWizardButtonContainer()); } }); updateExistingDataContainer.add(updateChkBox); add(updateExistingDataContainer); continueDespiteBadDataContainer = new WebMarkupContainer("continueDespiteBadDataContainer"); continueDespiteBadDataContainer.setOutputMarkupId(true); continueChkBox = new CheckBox("continueChkBox", new PropertyModel<Boolean>(this, "continueDespiteBadData")); continueChkBox.setVisible(true); continueChkBox.add(new AjaxFormComponentUpdatingBehavior("onChange") { private static final long serialVersionUID = -4514605801401294450L; @Override protected void onUpdate(AjaxRequestTarget target) { wizardForm.getNextButton().setEnabled(continueChkBox.getModelObject()); target.add(wizardForm.getWizardButtonContainer()); } }); continueDespiteBadDataContainer.add(continueChkBox); add(continueDespiteBadDataContainer); }
From source file:au.org.theark.study.web.component.subjectUpload.SubjectUploadStep3.java
License:Open Source License
@Override public void onStepInNext(AbstractWizardForm<?> form, AjaxRequestTarget target) { try {/*from w w w.j av a2 s. c o m*/ String filename = containerForm.getModelObject().getFileUpload().getClientFileName(); String fileFormat = filename.substring(filename.lastIndexOf('.') + 1).toUpperCase(); char delimiterChar = containerForm.getModelObject().getUpload().getDelimiterType() .getDelimiterCharacter(); InputStream inputStream = containerForm.getModelObject().getFileUpload().getInputStream(); HashSet<Integer> insertRows = new HashSet<Integer>(); HashSet<Integer> updateRows = new HashSet<Integer>(); HashSet<ArkGridCell> errorCells = new HashSet<ArkGridCell>(); //this is not the best way to do this fix TODO List<String> listOfUidsToUpdate = new ArrayList<String>(); if (containerForm.getModelObject().getUpload().getUploadType().getName() .equalsIgnoreCase(Constants.SUBJECT_DEMOGRAPHIC_DATA)) { SubjectUploadValidator subjectUploadValidator = new SubjectUploadValidator(iArkCommonService); validationMessages = subjectUploadValidator.validateSubjectFileData(containerForm.getModelObject(), listOfUidsToUpdate); containerForm.getModelObject().setUidsToUpload(listOfUidsToUpdate); insertRows = subjectUploadValidator.getInsertRows(); updateRows = subjectUploadValidator.getUpdateRows(); errorCells = subjectUploadValidator.getErrorCells(); } // custom field data two types of validation subject type or family type. else if (containerForm.getModelObject().getUpload().getUploadType().getName() .equalsIgnoreCase(Constants.STUDY_SPECIFIC_CUSTOM_DATA)) { CustomFieldUploadValidator customFieldUploadValidator = new CustomFieldUploadValidator( iArkCommonService); validationMessages = customFieldUploadValidator .validateCustomFieldFileData(containerForm.getModelObject(), listOfUidsToUpdate); containerForm.getModelObject().setUidsToUpload(listOfUidsToUpdate); //TODO consider if we want alternative way to do this - and maybe a superclass of uploadvalidator which draws out commonalities insertRows = customFieldUploadValidator.getInsertRows(); updateRows = customFieldUploadValidator.getUpdateRows(); errorCells = customFieldUploadValidator.getErrorCells(); } else if (containerForm.getModelObject().getUpload().getUploadType().getName() .equalsIgnoreCase(Constants.SUBJECT_CONSENT_DATA)) { SubjectConsentUploadValidator subjectConsentUploadValidator = new SubjectConsentUploadValidator( iArkCommonService); validationMessages = subjectConsentUploadValidator .validateSubjectConsentFileData(containerForm.getModelObject(), listOfUidsToUpdate); containerForm.getModelObject().setUidsToUpload(listOfUidsToUpdate); insertRows = subjectConsentUploadValidator.getInsertRows(); updateRows = subjectConsentUploadValidator.getUpdateRows(); errorCells = subjectConsentUploadValidator.getErrorCells(); } else if (containerForm.getModelObject().getUpload().getUploadType().getName() .equalsIgnoreCase(Constants.PEDIGREE_DATA)) { PedigreeUploadValidator pedigreeUploadValidator = new PedigreeUploadValidator(iArkCommonService, iStudyService); validationMessages = pedigreeUploadValidator .validatePedigreeFileData(containerForm.getModelObject(), listOfUidsToUpdate); warningMessages = pedigreeUploadValidator.getDataWarningMessages(); containerForm.getModelObject().setUidsToUpload(listOfUidsToUpdate); insertRows = pedigreeUploadValidator.getInsertRows(); updateRows = pedigreeUploadValidator.getUpdateRows(); errorCells = pedigreeUploadValidator.getErrorCells(); } else if (containerForm.getModelObject().getUpload().getUploadType().getName() .equalsIgnoreCase(Constants.SUBJECT_ATTACHMENT_DATA)) { SubjectAttachmentValidator subjectAttachmentValidator = new SubjectAttachmentValidator( iArkCommonService); validationMessages = subjectAttachmentValidator .validateSubjectAttachmentFileData(containerForm.getModelObject(), listOfUidsToUpdate); containerForm.getModelObject().setUidsToUpload(listOfUidsToUpdate); insertRows = subjectAttachmentValidator.getInsertRows(); updateRows = subjectAttachmentValidator.getUpdateRows(); errorCells = subjectAttachmentValidator.getErrorCells(); } else { //TODO : Throw error back to user } this.containerForm.getModelObject().setValidationMessages(validationMessages); validationMessage = containerForm.getModelObject().getValidationMessagesAsString(); addOrReplace(new MultiLineLabel("multiLineLabel", validationMessage)); // Show file data (and key reference) // ArkExcelWorkSheetAsGrid arkExcelWorkSheetAsGrid = new ArkExcelWorkSheetAsGrid("gridView", inputStream, fileFormat, delimiterChar, // containerForm.getModelObject().getFileUpload(), insertRows, updateRows, errorCells, containerForm.getModelObject().getUpload().getUploadType()); ArkExcelWorkSheetAsGrid arkExcelWorkSheetAsGrid = null; if (Constants.PEDIGREE_DATA .equalsIgnoreCase(containerForm.getModelObject().getUpload().getUploadType().getName())) { arkExcelWorkSheetAsGrid = new ArkExcelWorkSheetAsGrid("gridView", inputStream, fileFormat, delimiterChar, containerForm.getModelObject().getFileUpload(), iArkCommonService .getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue(), containerForm.getModelObject().getUpload().getUploadType(), false); } else { arkExcelWorkSheetAsGrid = new ArkExcelWorkSheetAsGrid("gridView", inputStream, fileFormat, delimiterChar, containerForm.getModelObject().getFileUpload(), iArkCommonService .getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue(), containerForm.getModelObject().getUpload().getUploadType()); } arkExcelWorkSheetAsGrid.setOutputMarkupId(true); arkExcelWorkSheetAsGrid.getWizardDataGridKeyContainer().setVisible(true); form.setArkExcelWorkSheetAsGrid(arkExcelWorkSheetAsGrid); form.getWizardPanelFormContainer().addOrReplace(arkExcelWorkSheetAsGrid); // Repaint target.add(arkExcelWorkSheetAsGrid.getWizardDataGridKeyContainer()); target.add(form.getWizardPanelFormContainer()); if (updateRows.isEmpty() || containerForm.getModelObject().getUpload().getUploadType().getName() .equalsIgnoreCase(Constants.STUDY_SPECIFIC_CUSTOM_DATA)) { updateExistingDataContainer.setVisible(false); target.add(updateExistingDataContainer); } if (!errorCells.isEmpty()) { updateExistingDataContainer.setVisible(false); target.add(updateExistingDataContainer); form.getNextButton().setEnabled(false); target.add(form.getWizardButtonContainer()); //TODO: consider invalid custom data to be warning cells rather than error cells continueDespiteBadDataContainer.setVisible(containerForm.getModelObject().getUpload() .getUploadType().getName().equalsIgnoreCase(Constants.STUDY_SPECIFIC_CUSTOM_DATA)); target.add(continueDespiteBadDataContainer); this.containerForm.getModelObject().getUpload() .setUploadStatus(iArkCommonService.getUploadStatusFor( au.org.theark.study.web.Constants.UPLOAD_STATUS_OF_ERROR_IN_DATA_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()); } else { continueDespiteBadDataContainer.setVisible(false); target.add(continueDespiteBadDataContainer); 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)); } containerForm.getModelObject().setValidationMessages(validationMessages); validationMessage = containerForm.getModelObject().getValidationMessagesAsString(); addOrReplace(new MultiLineLabel("multiLineLabel", validationMessage)); if (validationMessage != null && validationMessage.length() > 0) { form.getNextButton().setEnabled(continueChkBox.getModelObject()); target.add(form.getWizardButtonContainer()); downloadValMsgButton = new ArkDownloadAjaxButton("downloadValMsg", "ValidationMessage", validationMessage, "txt") { /** * */ private static final long serialVersionUID = 343293022422099247L; @Override protected void onError(AjaxRequestTarget target, Form<?> form) { this.error("Unexpected Error: Download request could not be processed"); } }; addOrReplace(downloadValMsgButton); target.add(downloadValMsgButton); } String warningMessage = getWarningMessagesAsString(); if (warningMessage != null && warningMessage.length() > 0) { addOrReplace(new MultiLineLabel("multiLineLabel", validationMessage + "\n " + warningMessage)); downloadValMsgButton = new ArkDownloadAjaxButton("downloadValMsg", "ValidationMessage", validationMessage + "\n" + warningMessage, "txt") { /** * */ private static final long serialVersionUID = 343293022422099247L; @Override protected void onError(AjaxRequestTarget target, Form<?> form) { this.error("Unexpected Error: Download request could not be processed"); } }; addOrReplace(downloadValMsgButton); target.add(downloadValMsgButton); } }
From source file:au.org.theark.study.web.component.subjectUpload.SubjectUploadStep4.java
License:Open Source License
@Override public void onStepOutNext(AbstractWizardForm<?> form, AjaxRequestTarget target) { form.getNextButton().setEnabled(false); target.add(form.getNextButton()); // Filename seems to be lost from model when moving between steps in wizard? is this a symptom of something greater? containerForm.getModelObject().getUpload().setFilename(wizardForm.getFileName()); String fileFormat = containerForm.getModelObject().getUpload().getFileFormat().getName(); char delimiterChar = containerForm.getModelObject().getUpload().getDelimiterType().getDelimiterCharacter(); try {/*from ww w .j a va 2 s. co m*/ List<String> uidsToUpload = containerForm.getModelObject().getUidsToUpload(); //log.info("________________________________________________________" + "about to try passing list of uids is of size " + uidsToUpload.size() ); InputStream inputStream = containerForm.getModelObject().getFileUpload().getInputStream(); long size = containerForm.getModelObject().getFileUpload().getSize(); Long uploadId = containerForm.getModelObject().getUpload().getId(); String report = generateInitialUploadReport(); Subject currentUser = SecurityUtils.getSubject(); Long studyId = (Long) currentUser.getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); if (containerForm.getModelObject().getUpload().getUploadType().getName() .equalsIgnoreCase(Constants.SUBJECT_DEMOGRAPHIC_DATA)) { StudyDataUploadExecutor task = new StudyDataUploadExecutor(iArkCommonService, iStudyService, inputStream, uploadId, //null user studyId, fileFormat, delimiterChar, size, report, uidsToUpload); task.run(); } else if (containerForm.getModelObject().getUpload().getUploadType().getName() .equalsIgnoreCase(Constants.STUDY_SPECIFIC_CUSTOM_DATA)) { SubjectCustomDataUploadExecutor task = new SubjectCustomDataUploadExecutor(iArkCommonService, iStudyService, inputStream, uploadId, //null user studyId, fileFormat, delimiterChar, size, report, uidsToUpload); task.run(); } else if (containerForm.getModelObject().getUpload().getUploadType().getName() .equalsIgnoreCase(Constants.SUBJECT_CONSENT_DATA)) { SubjectConsentDataUploadExecutor task = new SubjectConsentDataUploadExecutor(iArkCommonService, iStudyService, inputStream, uploadId, studyId, fileFormat, delimiterChar, size, report); task.run(); } else if (containerForm.getModelObject().getUpload().getUploadType().getName() .equalsIgnoreCase(Constants.PEDIGREE_DATA)) { PedigreeDataUploadExecutor task = new PedigreeDataUploadExecutor(iArkCommonService, iStudyService, inputStream, uploadId, studyId, fileFormat, delimiterChar, size, report); task.run(); } else if (containerForm.getModelObject().getUpload().getUploadType().getName() .equalsIgnoreCase(Constants.SUBJECT_ATTACHMENT_DATA)) { SubjectAttachmentDataUploadExecutor task = new SubjectAttachmentDataUploadExecutor( iArkCommonService, iStudyService, uploadId, studyId, fileFormat, inputStream, delimiterChar, size, report); task.run(); } } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } }
From source file:au.org.theark.web.pages.login.LoginForm.java
License:Open Source License
/** * LoginForm constructor/* ww w . j a va 2 s. c om*/ * * @param id * the Component identifier */ public LoginForm(String id) { // Pass in the Model to the Form so the IFormSubmitListener can set the Model Object with values that were submitted. super(id, new CompoundPropertyModel<ArkUserVO>(new ArkUserVO())); feedbackPanel.setOutputMarkupId(true); add(feedbackPanel); aafLogInButton = new AjaxButton("aafLogInButton") { private static final long serialVersionUID = 1L; @Override protected void onError(AjaxRequestTarget target, Form<?> form) { log.error("Error on aafLoginButton click"); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { setResponsePage(AAFLoginPage.class); } }; aafLogInButton.setDefaultFormProcessing(false); aafLogInButton.setVisible(ArkShibbolethServiceProviderContextSource.useShibboleth.equalsIgnoreCase("true")); signInButton = new AjaxButton("signInButton") { private static final long serialVersionUID = 1L; @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(feedbackPanel); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { ArkUserVO user = (ArkUserVO) getForm().getModelObject(); if (authenticate(user)) { DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); log.info("\n ---- " + user.getUserName() + " logged in successfully at: " + dateFormat.format(new Date()) + " ---- \n"); // Place a default module into session ArkModule arkModule = iArkCommonService .getArkModuleByName(au.org.theark.core.Constants.ARK_MODULE_STUDY); // Place a default function into session ArkFunction arkFunction = iArkCommonService .getArkFunctionByName(au.org.theark.core.Constants.FUNCTION_KEY_VALUE_STUDY); // Set session attributes SecurityUtils.getSubject().getSession().setAttribute(au.org.theark.core.Constants.ARK_USERID, user.getUserName()); SecurityUtils.getSubject().getSession() .setAttribute(au.org.theark.core.Constants.ARK_MODULE_KEY, arkModule.getId()); SecurityUtils.getSubject().getSession() .setAttribute(au.org.theark.core.Constants.ARK_FUNCTION_KEY, arkFunction.getId()); setResponsePage(HomePage.class); } else { setResponsePage(LoginPage.class); } target.add(feedbackPanel); } }; forgotPasswordButton = new Button("forgotPasswordButton") { private static final long serialVersionUID = 1L; @Override public void onSubmit() { setResponsePage(ResetPage.class); } @Override public void onError() { log.error("Error on click of forgotPasswordButton"); } }; forgotPasswordButton.setDefaultFormProcessing(false); addComponentsToForm(); }
From source file:au.org.theark.web.pages.mydetails.MyDetailModalWindow.java
License:Open Source License
protected void onCloseModalWindow(AjaxRequestTarget target) { target.add(form); target.add(panel); }
From source file:biz.turnonline.ecosystem.origin.frontend.myaccount.page.MyAccountBasics.java
License:Apache License
public MyAccountBasics() { add(new FirebaseAppInit(firebaseConfig)); final MyAccountModel accountModel = new MyAccountModel(); final IModel<Map<String, Country>> countriesModel = new CountriesModel(); setModel(accountModel);//from w w w. ja v a 2 s . c o m // form Form<Account> form = new Form<Account>("form", accountModel) { private static final long serialVersionUID = -938924956863034465L; @Override protected void onSubmit() { Account account = getModelObject(); send(getPage(), Broadcast.BREADTH, new AccountUpdateEvent(account)); } }; add(form); PropertyModel<Boolean> companyModel = new PropertyModel<>(accountModel, "company"); form.add(new CompanyPersonSwitcher("isCompanyRadioGroup", companyModel)); // account email fieldset form.add(new Label("email", new PropertyModel<>(accountModel, "email"))); // company basic info final CompanyBasicInfo<Account> basicInfo = new CompanyBasicInfo<Account>("companyData", accountModel) { private static final long serialVersionUID = -2992960490517951459L; @Override protected DropDownChoice<LegalForm> provideLegalForm(String componentId) { LegalFormListModel choices = new LegalFormListModel(); return new IndicatingAjaxDropDown<>(componentId, new LegalFormCodeModel(accountModel, "legalForm", choices), choices, new LegalFormRenderer()); } @Override protected void onConfigure() { super.onConfigure(); Account account = getModelObject(); this.setVisible(account.getCompany()); } }; form.add(basicInfo); // company basic info panel behaviors basicInfo.addLegalForm(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 6948210639258798921L; @Override protected void onUpdate(AjaxRequestTarget target) { } }); basicInfo.addVatId(new Behavior() { private static final long serialVersionUID = 100053137512632023L; @Override public void onConfigure(Component component) { super.onConfigure(component); Account account = basicInfo.getModelObject(); boolean visible; if (account == null || account.getBusiness() == null) { visible = true; } else { Boolean vatPayer = account.getBusiness().getVatPayer(); visible = vatPayer == null ? Boolean.FALSE : vatPayer; } component.setVisible(visible); } }); final TextField taxId = basicInfo.getTaxId(); final TextField vatId = basicInfo.getVatId(); final CheckBox vatPayer = basicInfo.getVatPayer(); basicInfo.addVatPayer(new AjaxFormSubmitBehavior(OnChangeAjaxBehavior.EVENT_NAME) { private static final long serialVersionUID = -1238082494184937003L; @Override protected void onSubmit(AjaxRequestTarget target) { Account account = (Account) basicInfo.getDefaultModelObject(); String rawTaxIdValue = taxId.getRawInput(); AccountBusiness business = account.getBusiness(); if (rawTaxIdValue != null && Strings.isEmpty(business == null ? null : business.getVatId())) { // VAT country prefix proposal String country = business == null ? "" : business.getDomicile(); country = country.toUpperCase(); //noinspection unchecked vatId.getModel().setObject(country + rawTaxIdValue); } // must be set manually as getDefaultProcessing() returns false vatPayer.setModelObject(!(business == null ? Boolean.FALSE : business.getVatPayer())); if (target != null) { target.add(vatId.getParent()); } } @Override public boolean getDefaultProcessing() { return false; } }); // personal data panel PersonalDataPanel<Account> personalData = new PersonalDataPanel<Account>("personalData", accountModel) { private static final long serialVersionUID = -2808922906891760016L; @Override protected void onConfigure() { super.onConfigure(); Account account = getModelObject(); this.setVisible(!account.getCompany()); } }; form.add(personalData); // personal address panel PersonalAddressPanel<Account> address = new PersonalAddressPanel<Account>("personalAddress", accountModel) { private static final long serialVersionUID = 3481146248010938807L; @Override protected DropDownChoice<Country> provideCountry(String componentId) { return new IndicatingAjaxDropDown<>(componentId, new PersonalAddressCountryModel(accountModel, countriesModel), new CountryRenderer(), countriesModel); } @Override protected void onConfigure() { super.onConfigure(); Account account = getModelObject(); this.setVisible(!account.getCompany()); } }; form.add(address); address.addCountry(new OnChangeAjaxBehavior() { private static final long serialVersionUID = -1016447969591778948L; @Override protected void onUpdate(AjaxRequestTarget target) { } }); // company address panel CompanyAddressPanel<Account> companyAddress; companyAddress = new CompanyAddressPanel<Account>("companyAddress", accountModel, false, false) { private static final long serialVersionUID = -6760545061622186549L; @Override protected DropDownChoice<Country> provideCountry(String componentId) { return new IndicatingAjaxDropDown<>(componentId, new CompanyDomicileModel(accountModel, countriesModel), new CountryRenderer(), countriesModel); } @Override protected void onConfigure() { super.onConfigure(); Account account = getModelObject(); this.setVisible(account.getCompany()); } }; form.add(companyAddress); companyAddress.addCountry(new OnChangeAjaxBehavior() { private static final long serialVersionUID = -5476413125490349124L; @Override protected void onUpdate(AjaxRequestTarget target) { } }); IModel<AccountPostalAddress> postalAddressModel = new PropertyModel<>(accountModel, "postalAddress"); IModel<Boolean> hasAddress = new PropertyModel<>(accountModel, "hasPostalAddress"); PostalAddressPanel<AccountPostalAddress> postalAddress; postalAddress = new PostalAddressPanel<AccountPostalAddress>("postal-address", postalAddressModel, hasAddress) { private static final long serialVersionUID = -930960688138308527L; @Override protected DropDownChoice<Country> provideCountry(String componentId) { return new IndicatingAjaxDropDown<>(componentId, new PostalAddressCountryModel(accountModel, countriesModel), new CountryRenderer(), countriesModel); } }; form.add(postalAddress); postalAddress.addStreet(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 4050800366443676166L; @Override protected void onUpdate(AjaxRequestTarget target) { } }); PropertyModel<Object> billingContactModel = PropertyModel.of(accountModel, "billingContact"); form.add(new SimplifiedContactFieldSet<>("contact", billingContactModel)); // save button form.add(new IndicatingAjaxButton("save", new I18NResourceModel("button.save"), form)); }
From source file:blg.bhdrkn.wicket.twitter.TwitterPage.java
License:Apache License
private void addTweetForm() { tweetForm = new Form<Void>("tweetForm"); tweetArea = new TextArea<String>("tweetArea", new PropertyModel<String>(this, "tweetModel")); tweetArea.setOutputMarkupId(true);// www . j a va2 s .c o m tweetForm.add(tweetArea); tweetForm.add(new AjaxButton("updateStatus") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { try { twitter = new TwitterFactory().getInstance(); twitter.setOAuthConsumer(SocialMedia.TWITTER_CONSUMER_KEY, SocialMedia.TWITTER_CONSUMER_SECRET); twitter.setOAuthAccessToken(token); twitter.updateStatus(tweetModel); target.appendJavaScript("alert('Status Updated: " + tweetModel + "');"); tweetModel = ""; target.add(tweetArea); } catch (TwitterException e) { logger.error("Error While Updating the Status"); e.printStackTrace(); } } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { logger.error("Error Before Updating the Status"); } }); add(tweetForm); }