List of usage examples for org.apache.wicket.markup.html WebMarkupContainer setOutputMarkupId
public final Component setOutputMarkupId(final boolean output)
From source file:abid.password.wicket.pages.LoginPage.java
License:Apache License
public LoginPage() { LoginPanel loginPanel = new LoginPanel("loginPanel"); add(loginPanel);/*from www . j a v a2s . com*/ LoadableDetachableModel<List<User>> usersModel = new LoadableDetachableModel<List<User>>() { private static final long serialVersionUID = 1L; @Override protected List<User> load() { return userService.getUsers(); } }; PageableListView<User> dataList = new PageableListView<User>("usersList", usersModel, 100) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<User> item) { final User data = item.getModelObject(); Label userLabel = new Label("userLabel", data.getUsername()); Label passLabel = new Label("passLabel", data.getPassword()); try { Password password = new MutablePasswordParser().parse(data.getPassword()); if (password instanceof MutablePassword) { MutablePassword mutablePassword = (MutablePassword) password; String evalatedPassword = mutablePassword.getEvaluatedPassword(); passLabel = new Label("passLabel", evalatedPassword); } } catch (Exception e) { log.error("Could not create the mutable password", e); } item.add(userLabel); item.add(passLabel); } }; int refreshTime = 3; final WebMarkupContainer usersContainer = new WebMarkupContainer("usersContainer"); usersContainer.setOutputMarkupId(true); usersContainer.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(refreshTime))); usersContainer.add(dataList); String refreshInformation = String.format("Password refreshes every %s seconds.", refreshTime); String javascriptDisabledMsg = "Javascript is disabled you will need to refresh the page manually."; AjaxFallbackLabel refreshLabel = new AjaxFallbackLabel("refreshInformation", refreshInformation, javascriptDisabledMsg); add(usersContainer); add(refreshLabel); }
From source file:abid.password.wicket.pages.UsersPage.java
License:Apache License
public UsersPage() { LoadableDetachableModel<List<User>> usersModel = new LoadableDetachableModel<List<User>>() { private static final long serialVersionUID = 1L; @Override// ww w .j a v a2 s.c om protected List<User> load() { return userService.getUsers(); } }; PageableListView<User> dataList = new PageableListView<User>("usersList", usersModel, 100) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<User> item) { final User data = item.getModelObject(); Label userLabel = new Label("userLabel", data.getUsername()); Label passLabel = new Label("passLabel", data.getPassword()); try { Password password = new MutablePasswordParser().parse(data.getPassword()); if (password instanceof MutablePassword) { MutablePassword mutablePassword = (MutablePassword) password; String evalatedPassword = mutablePassword.getEvaluatedPassword(); passLabel = new Label("passLabel", evalatedPassword); } } catch (Exception e) { log.error("Could not create the mutable password", e); } item.add(userLabel); item.add(passLabel); } }; int refreshTime = 3; final WebMarkupContainer dataContainer = new WebMarkupContainer("dataContainer"); dataContainer.setOutputMarkupId(true); dataContainer.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(refreshTime))); dataContainer.add(dataList); String refreshInformation = String.format("Password refreshes every %s seconds.", refreshTime); String javascriptDisabledMsg = "Javascript is disabled you will need to refresh the page manually."; AjaxFallbackLabel refreshInfoLabel = new AjaxFallbackLabel("refreshInformation", refreshInformation, javascriptDisabledMsg); add(dataContainer); add(refreshInfoLabel); }
From source file:at.ac.tuwien.ifs.tita.ui.evaluation.timeconsumer.DailyViewPage.java
License:Apache License
/** * Inits Page./* w w w . j a v a 2 s. c o m*/ */ private void initPage() { Form<Effort> form = new Form<Effort>("timeConsumerEvaluationForm", new CompoundPropertyModel<Effort>(new Effort())); add(form); form.setOutputMarkupId(true); final DateTextField dateTextField = new DateTextField("tedate", new PropertyModel<Date>(this, "date"), new StyleDateConverter("S-", true)); dateTextField.add(new DatePicker()); form.add(dateTextField); final WebMarkupContainer timeeffortContainer = new WebMarkupContainer("timeeffortContainer"); timeeffortContainer.setOutputMarkupId(true); timeeffortContainer.setOutputMarkupPlaceholderTag(true); add(timeeffortContainer); tableModel = new TableModelTimeConsumerEvaluation(getTimeEffortsDailyView(new Date())); Table table = new Table("tetable", tableModel); timeeffortContainer.add(table); final Button btnShowAsPDF = new Button("btnShowPDF") { @Override public void onSubmit() { try { loadReport(); ResourceStreamRequestTarget rsrtarget = new ResourceStreamRequestTarget( pdfResource.getResourceStream()); rsrtarget.setFileName(pdfResource.getFilename()); RequestCycle.get().setRequestTarget(rsrtarget); } catch (JRException e) { // TODO: GUI Exception Handling log.error(e.getMessage()); } catch (PersistenceException e) { // TODO: GUI Exception Handling log.error(e.getMessage()); } } @Override public boolean isEnabled() { return tableModel.getRowCount() == 0 ? false : true; } }; form.add(btnShowAsPDF); form.add(new AjaxButton("btnShowEvaluation", form) { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form1) { tableModel.reload(getTimeEffortsDailyView(dateTextField.getModelObject())); target.addComponent(timeeffortContainer); target.addComponent(btnShowAsPDF); } @Override protected void onError(AjaxRequestTarget target, Form<?> form1) { // TODO Set border red on textfields which are'nt filled } }); }
From source file:at.ac.tuwien.ifs.tita.ui.evaluation.timeconsumer.MonthlyViewPage.java
License:Apache License
/** * Inits Page.//from w w w. ja v a 2 s .c o m */ @SuppressWarnings("unchecked") private void initPage() { Form<Effort> form = new Form<Effort>("timeConsumerEvaluationForm", new CompoundPropertyModel<Effort>(new Effort())); add(form); form.setOutputMarkupId(true); ChoiceRenderer choiceRenderer = new ChoiceRenderer("value", "key"); final DropDownChoice ddYears = new DropDownChoice("yearSelection", new PropertyModel(this, "selectedYear"), getYears(), choiceRenderer); form.add(ddYears); final DropDownChoice ddMonths = new DropDownChoice("monthSelection", new PropertyModel(this, "selectedMonth"), getMonths(), choiceRenderer); form.add(ddMonths); final WebMarkupContainer timeeffortContainer = new WebMarkupContainer("timeeffortContainer"); timeeffortContainer.setOutputMarkupId(true); timeeffortContainer.setOutputMarkupPlaceholderTag(true); add(timeeffortContainer); initButtons(form, timeeffortContainer); Calendar cal = Calendar.getInstance(); tableModel = new TableModelTimeConsumerEvaluation( getTimeEffortsMonthlyView(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH))); Table table = new Table("tetable", tableModel); timeeffortContainer.add(table); }
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 {//www. j a va 2 s . 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 ww w.j ava 2 s .c o 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.subjectUpload.SubjectUploadStep2.java
License:Open Source License
@Override public void onStepInNext(AbstractWizardForm<?> form, AjaxRequestTarget target) { try {/*from ww w .j a v a2 s. c om*/ 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 ww . j a v a2 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 ww. ja va2 s .com*/ 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:com.aplombee.examples.AjaxLinkPage.java
License:Apache License
@Override protected void onInitialize() { super.onInitialize(); IDataProvider<Integer> data = new ListDataProvider<Integer>(list); WebMarkupContainer numbers = new WebMarkupContainer("numbers"); //parent for quickview numbers.setOutputMarkupId(true); //needed for ajax final QuickView<Integer> number = new QuickView<Integer>("number", data, new ItemsNavigationStrategy()) { @Override//from ww w . jav a 2s .c o m protected void populate(Item<Integer> item) { item.add(new Label("display", item.getModel())); } }; numbers.add(number); add(numbers); AjaxLink addLink = new AjaxLink("addLink") { @Override public void onClick(AjaxRequestTarget target) { int newObject = list.get(list.size() - 1) + 1; list.add(newObject); number.addNewItems(newObject); //just enough to create a new row at last } }; addLink.setOutputMarkupPlaceholderTag(true); add(addLink); AjaxLink addAtStartLink = new AjaxLink("addAtStartLink") { @Override public void onClick(AjaxRequestTarget target) { int newObject = list.get(0) - 1; list.add(0, newObject); number.addNewItemsAtStart(newObject); //just enough to create a new row at start } }; addAtStartLink.setOutputMarkupPlaceholderTag(true); add(addAtStartLink); }