List of usage examples for org.apache.wicket.ajax.markup.html AjaxLink AjaxLink
public AjaxLink(final String id)
From source file:aqubi.samples.wicket.page.extension.ModalContentPage.java
License:Apache License
/** * //from w ww . j ava 2 s.c o m * @param modalWindowPage * @param window */ @SuppressWarnings("serial") public ModalContentPage(final ModalWindowPage modalWindowPage, final ModalWindow window) { add(new AjaxLink<Void>("closeOK") { public void onClick(AjaxRequestTarget target) { if (modalWindowPage != null) modalWindowPage.setResult("Modal window - close link OK"); window.close(target); } }); add(new AjaxLink<Void>("closeCancel") { public void onClick(AjaxRequestTarget target) { if (modalWindowPage != null) modalWindowPage.setResult("Modal window - close link Cancel"); window.close(target); } }); }
From source file:ar.com.nybble.futbol.view.TemplatePage.java
License:Apache License
/** * Constructor/* w w w . j a v a 2s . com*/ */ public TemplatePage() { add(new Label("title", new PropertyModel<String>(this, "pageTitle"))); tree = new LinkTree("tree", createTreeModel()) { @Override protected void onNodeLinkClicked(Object node, BaseTree tree, AjaxRequestTarget target) { super.onNodeLinkClicked(node, tree, target); ModelBean clase = (ModelBean) ((DefaultMutableTreeNode) node).getUserObject(); if (clase.isLinkiable()) { setResponsePage(((Class) clase.getContent())); } else tree.getTreeState().expandNode(node); } }; add(tree); tree.getTreeState().collapseAll(); add(new AjaxLink("expandAll") { @Override public void onClick(AjaxRequestTarget target) { getTree().getTreeState().expandAll(); getTree().updateTree(target); } }); add(new AjaxLink("collapseAll") { @Override public void onClick(AjaxRequestTarget target) { getTree().getTreeState().collapseAll(); getTree().updateTree(target); } }); }
From source file:au.org.theark.lims.web.component.subjectlims.lims.biospecimen.form.BiospecimenModalDetailForm.java
License:Open Source License
public void initialiseDetailForm() { idTxtFld = new TextField<String>("biospecimen.id"); biospecimenUidTxtFld = new TextField<String>("biospecimen.biospecimenUid"); biospecimenUidTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; @Override//from w w w .java 2s . co m protected void onUpdate(AjaxRequestTarget target) { // Check BiospecimenUID is unique String biospecimenUid = (getComponent().getDefaultModelObject().toString() != null ? getComponent().getDefaultModelObject().toString() : new String()); Biospecimen biospecimen = iLimsService.getBiospecimenByUid(biospecimenUid, cpModel.getObject().getBiospecimen().getStudy()); if (biospecimen != null && biospecimen.getId() != null) { error("Biospecimen UID must be unique. Please try again."); target.focusComponent(getComponent()); } target.add(feedbackPanel); } }); parentUidTxtFld = new TextField<String>("biospecimen.parentUid"); commentsTxtAreaFld = new TextArea<String>("biospecimen.comments"); sampleDateTxtFld = new DateTextField("biospecimen.sampleDate", au.org.theark.core.Constants.DD_MM_YYYY); useCollectionDate = new AjaxLink<Date>("useCollectionDate") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { BioCollection selectedBioCollection = cpModel.getObject().getBioCollection(); cpModel.getObject().getBiospecimen().setSampleDate(selectedBioCollection.getCollectionDate()); target.add(sampleDateTxtFld); } }; sampleTimeTxtFld = new TimeField("biospecimen.sampleTime") { private static final long serialVersionUID = 1L; @Override protected void onBeforeRender() { this.getDateTextField().setVisibilityAllowed(false); super.onBeforeRender(); } @Override protected void convertInput() { // Slight change to not default to today's date Date modelObject = (Date) getDefaultModelObject(); getDateTextField().setConvertedInput(modelObject != null ? modelObject : null); super.convertInput(); } }; processedDateTxtFld = new DateTextField("biospecimen.processedDate", au.org.theark.core.Constants.DD_MM_YYYY); processedTimeTxtFld = new TimeField("biospecimen.processedTime") { private static final long serialVersionUID = 1L; @Override protected void onBeforeRender() { this.getDateTextField().setVisibilityAllowed(false); super.onBeforeRender(); } @Override protected void convertInput() { // Slight change to not default to today's date Date modelObject = (Date) getDefaultModelObject(); getDateTextField().setConvertedInput(modelObject != null ? modelObject : null); super.convertInput(); } }; ArkDatePicker sampleDatePicker = new ArkDatePicker(); sampleDatePicker.bind(sampleDateTxtFld); sampleDateTxtFld.add(sampleDatePicker); ArkDatePicker processedDatePicker = new ArkDatePicker(); processedDatePicker.bind(processedDateTxtFld); processedDateTxtFld.add(processedDatePicker); quantityTxtFld = new TextField<Double>("biospecimen.quantity") { private static final long serialVersionUID = 1L; @SuppressWarnings("unchecked") @Override public <C> IConverter<C> getConverter(Class<C> type) { DoubleConverter doubleConverter = new DoubleConverter(); NumberFormat numberFormat = NumberFormat.getInstance(); numberFormat.setMinimumFractionDigits(1); numberFormat.setMaximumFractionDigits(10); doubleConverter.setNumberFormat(getLocale(), numberFormat); return (IConverter<C>) doubleConverter; } }; parentQuantityTxtFld = new TextField<Double>("parentBiospecimen.quantity") { private static final long serialVersionUID = 1L; @SuppressWarnings("unchecked") @Override public <C> IConverter<C> getConverter(Class<C> type) { DoubleConverter doubleConverter = new DoubleConverter(); NumberFormat numberFormat = NumberFormat.getInstance(); numberFormat.setMinimumFractionDigits(1); numberFormat.setMaximumFractionDigits(10); doubleConverter.setNumberFormat(getLocale(), numberFormat); return (IConverter<C>) doubleConverter; } }; parentQuantityTxtFld.setVisible(cpModel.getObject().getBiospecimenProcessing() .equalsIgnoreCase(au.org.theark.lims.web.Constants.BIOSPECIMEN_PROCESSING_PROCESSING)); parentQuantityTxtFld.setOutputMarkupId(true); quantityTxtFld.setEnabled(false); bioTransactionQuantityTxtFld = new TextField<Double>("bioTransaction.quantity") { private static final long serialVersionUID = 1L; @SuppressWarnings("unchecked") @Override public <C> IConverter<C> getConverter(Class<C> type) { DoubleConverter doubleConverter = new DoubleConverter(); NumberFormat numberFormat = NumberFormat.getInstance(); numberFormat.setMinimumFractionDigits(1); numberFormat.setMaximumFractionDigits(10); doubleConverter.setNumberFormat(getLocale(), numberFormat); return (IConverter<C>) doubleConverter; } }; bioTransactionQuantityTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { target.add(amountLbl); } }); concentrationTxtFld = new TextField<Number>("biospecimen.concentration"); concentrationTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { target.add(amountLbl); } }); amountLbl = new Label("biospecimen.amount", new Model<Number>() { private static final long serialVersionUID = 1L; @Override public Number getObject() { Number concentration = ((concentrationTxtFld.getModelObject() == null) ? 0 : concentrationTxtFld.getModelObject()); Number quantity = null; if (bioTransactionQuantityTxtFld.isVisible()) { quantity = ((bioTransactionQuantityTxtFld.getModelObject() == null) ? 0 : bioTransactionQuantityTxtFld.getModelObject()); } else { quantity = ((quantityTxtFld.getModelObject() == null) ? 0 : quantityTxtFld.getModelObject()); } Number amount = (concentration.doubleValue() * quantity.doubleValue()); return amount; } }); amountLbl.setOutputMarkupPlaceholderTag(true); setQuantityLabel(); initSampleTypeDdc(); initBioCollectionDdc(); initUnitDdc(); initTreatmentTypeDdc(); initGradeDdc(); initStoredInDdc(); initAnticoagDdc(); initStatusDdc(); initQualityDdc(); initBiospecimenProtocol(); purity = new TextField<Number>("biospecimen.purity"); barcodedChkBox = new CheckBox("biospecimen.barcoded"); barcodedChkBox.setVisible(true); barcodedChkBox.setEnabled(false); initialiseBarcodeImage(); initialiseBiospecimenCFDataEntry(); initialiseBioTransactionListPanel(); initialiseBiospecimenLocationPanel(); initialiseBiospecimenButtonsPanel(); initDeleteModelWindow(); attachValidators(); addComponents(); // Focus on Sample Type sampleTypeDdc.add(new ArkDefaultFormFocusBehavior()); }
From source file:au.org.theark.report.web.component.dataextraction.form.DetailForm.java
License:Open Source License
public void initialiseDetailForm() { arkCrudContainerVO.getDetailPanelFormContainer().add(modalWindow); searchIdTxtFld = new TextField<String>(Constants.SEARCH_ID); searchIdTxtFld.setEnabled(false);/* w w w . j a v a 2s . c o m*/ searchNameTxtFld = new TextField<String>(Constants.SEARCH_NAME); searchNameTxtFld.add(new ArkDefaultFormFocusBehavior()); modalContentPanel = new EmptyPanel("content"); initIncludeGeno(); initDemographicFieldsModulePalette(); initBiospecimenFieldsModulePalette(); initBiocollectionFieldsModulePalette(); initPhenoDataSetFieldDisplaysModulePalette(); initSubjectCustomFieldDisplaysModulePalette(); initBiospecimenCustomFieldDisplaysModulePalette(); initBiocollectionCustomFieldDisplaysModulePalette(); initConsentStatusFieldsModulePalette(); arkCrudContainerVO.getDetailPanelFormContainer().add(subjectListFileUploadField); arkCrudContainerVO.getDetailPanelFormContainer().add(new AjaxLink("downloadSubjectList") { @Override public void onClick(AjaxRequestTarget target) { // TODO Auto-generated method stub target.appendJavaScript("alert('Link clicked');"); } }); clearButton = new AjaxButton("clearButton") { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { subjectListFileUploadField.clearInput(); target.add(subjectListFileUploadField); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { subjectListFileUploadField.clearInput(); target.add(subjectListFileUploadField); } }; clearButton.add(new AttributeModifier("title", new Model<String>("Clear Attachment"))); addDetailFormComponents(); attachValidators(); }
From source file:au.org.theark.report.web.component.viewReport.ReportSelectPanel.java
License:Open Source License
@SuppressWarnings({ "unchecked" }) private AjaxLink buildLink(final ReportTemplate reportTemplate) { AjaxLink link = new AjaxLink("reportTemplate.link") { private static final long serialVersionUID = 1L; @Override/*from w ww.ja v a2 s .c o m*/ public void onClick(AjaxRequestTarget target) { // Perform security check upon selection of the report Subject subject = SecurityUtils.getSubject(); boolean securityCheckOk = false; try { String userRole = iArkCommonService.getUserRole(subject.getPrincipal().toString(), reportTemplate.getFunction(), reportTemplate.getModule(), reportSelectCPM.getObject().getStudy()); if (userRole.length() > 0) { securityCheckOk = true; } } catch (EntityNotFoundException e) { // TODO I don't like this kind of code - if there isn't a record, we should just return NULL. // Only if it really is an error to not have a record, then we should throw an exception. } if (securityCheckOk == false) { this.error( "You do not have enough privileges to access this report. If you believe this is incorrect, then please contact your administrator."); } else if (reportTemplate.getName().equals(Constants.STUDY_SUMMARY_REPORT_NAME)) { if (reportSelectCPM.getObject().getStudy() == null) { this.error("This report requires a study in context. Please put a study in context first."); } else { StudySummaryReportContainer selectedReportPanel = new StudySummaryReportContainer( "selectedReportContainerPanel"); selectedReportPanel.setOutputMarkupId(true); // Replace the old selectedReportPanel with this new one reportContainerVO.getSelectedReportPanel().replaceWith(selectedReportPanel); reportContainerVO.setSelectedReportPanel(selectedReportPanel); selectedReportPanel.initialisePanel(reportContainerVO.getFeedbackPanel(), reportTemplate); target.add(reportContainerVO.getSelectedReportContainerWMC()); this.info(reportTemplate.getName() + " template selected."); } } else if (reportTemplate.getName().equals(Constants.STUDY_LEVEL_CONSENT_REPORT_NAME)) { if (reportSelectCPM.getObject().getStudy() == null) { this.error("This report requires a study in context. Please put a study in context first."); } else { StudyLevelConsentReportContainer selectedReportPanel = new StudyLevelConsentReportContainer( "selectedReportContainerPanel"); selectedReportPanel.setOutputMarkupId(true); // Replace the old selectedReportPanel with this new one reportContainerVO.getSelectedReportPanel().replaceWith(selectedReportPanel); reportContainerVO.setSelectedReportPanel(selectedReportPanel); selectedReportPanel.initialisePanel(reportContainerVO.getFeedbackPanel(), reportTemplate); target.add(reportContainerVO.getSelectedReportContainerWMC()); this.info(reportTemplate.getName() + " template selected."); } } else if (reportTemplate.getName().equals(Constants.STUDY_COMP_CONSENT_REPORT_NAME)) { if (reportSelectCPM.getObject().getStudy() == null) { this.error("This report requires a study in context. Please put a study in context first."); } else { ConsentDetailsReportContainer selectedReportPanel = new ConsentDetailsReportContainer( "selectedReportContainerPanel"); selectedReportPanel.setOutputMarkupId(true); // Replace the old selectedReportPanel with this new one reportContainerVO.getSelectedReportPanel().replaceWith(selectedReportPanel); reportContainerVO.setSelectedReportPanel(selectedReportPanel); selectedReportPanel.initialisePanel(reportContainerVO.getFeedbackPanel(), reportTemplate); target.add(reportContainerVO.getSelectedReportContainerWMC()); this.info(reportTemplate.getName() + " template selected."); } } else if (reportTemplate.getName().equals(Constants.PHENO_FIELD_DETAILS_REPORT_NAME)) { if (reportSelectCPM.getObject().getStudy() == null) { this.error("This report requires a study in context. Please put a study in context first."); } else { PhenoFieldDetailsReportContainer selectedReportPanel = new PhenoFieldDetailsReportContainer( "selectedReportContainerPanel"); selectedReportPanel.setOutputMarkupId(true); // Replace the old selectedReportPanel with this new one reportContainerVO.getSelectedReportPanel().replaceWith(selectedReportPanel); reportContainerVO.setSelectedReportPanel(selectedReportPanel); selectedReportPanel.initialisePanel(reportContainerVO.getFeedbackPanel(), reportTemplate); target.add(reportContainerVO.getSelectedReportContainerWMC()); this.info(reportTemplate.getName() + " template selected."); } } else if (reportTemplate.getName().equals(Constants.STUDY_USER_ROLE_PERMISSIONS)) { if (reportSelectCPM.getObject().getStudy() == null) { this.error("This report requires a study in context. Please put a study in context first."); } else { StudyUserRolePermissionsReportContainer selectedReportPanel = new StudyUserRolePermissionsReportContainer( "selectedReportContainerPanel"); selectedReportPanel.setOutputMarkupId(true); // Replace the old selectedReportPanel with this new one reportContainerVO.getSelectedReportPanel().replaceWith(selectedReportPanel); reportContainerVO.setSelectedReportPanel(selectedReportPanel); selectedReportPanel.initialisePanel(reportContainerVO.getFeedbackPanel(), reportTemplate); target.add(reportContainerVO.getSelectedReportContainerWMC()); this.info(reportTemplate.getName() + " template selected."); } } else if (reportTemplate.getName().equals(Constants.WORK_RESEARCHER_COST_REPORT_NAME)) { if (reportSelectCPM.getObject().getStudy() == null) { this.error("This report requires a study in context. Please put a study in context first."); } else { WorkResearcherCostReportContainer selectedReportPanel = new WorkResearcherCostReportContainer( "selectedReportContainerPanel"); selectedReportPanel.setOutputMarkupId(true); // Replace the old selectedReportPanel with this new one reportContainerVO.getSelectedReportPanel().replaceWith(selectedReportPanel); reportContainerVO.setSelectedReportPanel(selectedReportPanel); selectedReportPanel.initialisePanel(reportContainerVO.getFeedbackPanel(), reportTemplate); target.add(reportContainerVO.getSelectedReportContainerWMC()); this.info(reportTemplate.getName() + " template selected."); } } else if (reportTemplate.getName().equals(Constants.WORK_RESEARCHER_DETAIL_COST_REPORT_NAME)) { if (reportSelectCPM.getObject().getStudy() == null) { this.error("This report requires a study in context. Please put a study in context first."); } else { WorkResearcherDetailCostReportContainer selectedReportPanel = new WorkResearcherDetailCostReportContainer( "selectedReportContainerPanel"); selectedReportPanel.setOutputMarkupId(true); // Replace the old selectedReportPanel with this new one reportContainerVO.getSelectedReportPanel().replaceWith(selectedReportPanel); reportContainerVO.setSelectedReportPanel(selectedReportPanel); selectedReportPanel.initialisePanel(reportContainerVO.getFeedbackPanel(), reportTemplate); target.add(reportContainerVO.getSelectedReportContainerWMC()); this.info(reportTemplate.getName() + " template selected."); } } else if (reportTemplate.getName().equals(Constants.WORK_STUDY_DETAIL_COST_REPORT_NAME)) { if (reportSelectCPM.getObject().getStudy() == null) { this.error("This report requires a study in context. Please put a study in context first."); } else { StudyCostReportContainer selectedReportPanel = new StudyCostReportContainer( "selectedReportContainerPanel"); selectedReportPanel.setOutputMarkupId(true); // Replace the old selectedReportPanel with this new one reportContainerVO.getSelectedReportPanel().replaceWith(selectedReportPanel); reportContainerVO.setSelectedReportPanel(selectedReportPanel); selectedReportPanel.initialisePanel(reportContainerVO.getFeedbackPanel(), reportTemplate); target.add(reportContainerVO.getSelectedReportContainerWMC()); this.info(reportTemplate.getName() + " template selected."); } } else if (reportTemplate.getName().equals(Constants.LIMS_BIOSPECIMEN_SUMMARY_REPORT_NAME)) { BiospecimenSummaryReportContainer selectedReportPanel = new BiospecimenSummaryReportContainer( "selectedReportContainerPanel"); selectedReportPanel.setOutputMarkupId(true); // Replace the old selectedReportPanel with this new one reportContainerVO.getSelectedReportPanel().replaceWith(selectedReportPanel); reportContainerVO.setSelectedReportPanel(selectedReportPanel); selectedReportPanel.initialisePanel(reportContainerVO.getFeedbackPanel(), reportTemplate); target.add(reportContainerVO.getSelectedReportContainerWMC()); this.info(reportTemplate.getName() + " template selected."); } else if (reportTemplate.getName().equals(Constants.LIMS_BIOSPECIMEN_DETAIL_REPORT_NAME)) { BiospecimenDetailsReportContainer selectedReportPanel = new BiospecimenDetailsReportContainer( "selectedReportContainerPanel"); selectedReportPanel.setOutputMarkupId(true); // Replace the old selectedReportPanel with this new one reportContainerVO.getSelectedReportPanel().replaceWith(selectedReportPanel); reportContainerVO.setSelectedReportPanel(selectedReportPanel); selectedReportPanel.initialisePanel(reportContainerVO.getFeedbackPanel(), reportTemplate); target.add(reportContainerVO.getSelectedReportContainerWMC()); this.info(reportTemplate.getName() + " template selected."); } else { this.error("System error: " + reportTemplate.getName() + " has no implementation or has been deprecated."); } target.add(reportContainerVO.getFeedbackPanel()); } }; // Add the label for the link Label nameLinkLabel = new Label("reportTemplate.name", reportTemplate.getName()); link.add(nameLinkLabel); return link; }
From source file:au.org.theark.study.web.component.manageuser.SearchResultListPanel.java
License:Open Source License
private AjaxLink buildLink(final ArkUserVO arkUserVo, final WebMarkupContainer searchResultsContainer) { AjaxLink link = new AjaxLink("userName") { private static final long serialVersionUID = 1L; @Override//from ww w. ja v a2 s . c om public void onClick(AjaxRequestTarget target) { try { // Fetch the user and related details from backend Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); Study study = iArkCommonService.getStudy(sessionStudyId); ArkUserVO arkUserVOFromBackend = iUserService.lookupArkUser(arkUserVo.getUserName(), study); if (!arkUserVOFromBackend.isArkUserPresentInDatabase()) { containerForm .info(new StringResourceModel("user.not.linked.to.study", this, null).getString()); target.add(feedbackPanel); arkUserVOFromBackend.setChangePassword(true); arkUserVOFromBackend.getArkUserEntity().setLdapUserName(arkUserVo.getUserName()); arkUserVOFromBackend.setStudy(new Study()); prePopulateForNewUser(arkUserVOFromBackend); } else { arkUserVOFromBackend.setStudy(study); prePopulateArkUserRoleList(arkUserVOFromBackend); } containerForm.getModelObject().setArkUserRoleList(arkUserVOFromBackend.getArkUserRoleList()); containerForm.setModelObject(arkUserVOFromBackend); // This triggers the call to populateItem() of the ListView ListView listView = (ListView) arkCrudContainerVO.getWmcForarkUserAccountPanel() .get("arkUserRoleList"); if (listView != null) { listView.removeAll(); } arkCrudContainerVO.getWmcForarkUserAccountPanel().setVisible(true); ArkCRUDHelper.preProcessDetailPanelOnSearchResults(target, arkCrudContainerVO); target.add(feedbackPanel); // Set the MODE here.Since the User Details are from LDAP we don't have a entity that we can use to check for a mode containerForm.getModelObject().setMode(Constants.MODE_EDIT); // Available/assigned child studies List<Study> availableChildStudies = new ArrayList<Study>(0); List<Study> selectedChildStudies = new ArrayList<Study>(0); if (study.getParentStudy() != null && study.getParentStudy() == study) { availableChildStudies = iStudyService.getChildStudyListOfParent(study); // Only assign selected child studies if/when user actually assigned study in context if (arkUserVOFromBackend.getStudy().getId() != null) { selectedChildStudies = iArkCommonService .getAssignedChildStudyListForUser(arkUserVOFromBackend); } } containerForm.getModelObject().setAvailableChildStudies(availableChildStudies); containerForm.getModelObject().setSelectedChildStudies(selectedChildStudies); } catch (ArkSystemException e) { containerForm.error(new StringResourceModel("ark.system.error", this, null).getString()); target.add(feedbackPanel); } } }; // Add the label for the link Label userNameLinkLabel = new Label("userNameLink", arkUserVo.getUserName()); link.add(userNameLinkLabel); return link; }
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 av a 2 s . c om*/ 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);//from w ww. ja va2s . 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:ca.travelagency.invoice.view.InvoiceViewLink.java
License:Apache License
public InvoiceViewLink(String id, IModel<Invoice> model) { super(id);/* w w w . j av a 2 s.c om*/ invoiceModalWindow = new InvoiceModalWindow(LINK_MODALWINDOW, model); add(invoiceModalWindow); AjaxLink<Invoice> link = new AjaxLink<Invoice>(LINK) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { invoiceModalWindow.show(target); } }; add(link); }
From source file:ca.travelagency.traveler.SelectPanel.java
License:Apache License
public SelectPanel(String id, final IModel<Traveler> model, final Form<InvoiceTraveler> travelerForm, final ModalWindow modalWindow) { super(id);/*w ww . ja v a2 s.co m*/ AjaxLink<Void> link = new AjaxLink<Void>(LINK) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { travelerForm.getModelObject().copy(model.getObject()); target.add(travelerForm); modalWindow.close(target); target.appendJavaScript(JSUtils.INITIALIZE); } }; link.add(new Label(LABEL, Model.of(model.getObject().getName()))); add(link); }