List of usage examples for com.vaadin.server UserError UserError
public UserError(String textErrorMessage)
From source file:com.gnts.pem.txn.synd.SyndFlat.java
License:Open Source License
private void saveEvaluationDetails() { uiflowdata = new UIFlowData(); // for save evaluation details boolean valid = false; try {/* ww w . ja va2s . co m*/ TPemCmEvalDetails evalobj = new TPemCmEvalDetails(); evalobj.setDocId(headerid); evalobj.setDocDate(dfDateofValuation.getValue()); evalobj.setEvalNo(tfEvaluationNumber.getValue()); evalobj.setEvalDate(dfDateofValuation.getValue()); evalobj.setValuationBy(tfValuatedBy.getValue()); MPemCmBank bankid = new MPemCmBank(); bankid.setBankId(selectedBankid); evalobj.setBankId(bankid); evalobj.setDoctype(screenName); evalobj.setCompanyId(selectCompanyid); evalobj.setBankBranch((String) slBankBranch.getValue()); evalobj.setEvalPurpose(tfEvaluationPurpose.getValue()); evalobj.setCheckedBy(tfVerifiedBy.getValue()); evalobj.setCheckedDt(dfVerifiedDate.getValue()); evalobj.setInspectionDt(dfDateofValuation.getValue()); evalobj.setInspectionBy(tfValuatedBy.getValue()); evalobj.setDocStatus(Common.DOC_DRAFT); evalobj.setLastUpdateDt(new Date()); evalobj.setLastUpdtedBy(loginusername); evalobj.setCustName(tfCustomerName.getValue()); if (tfDynamicEvaluation1.getValue() != null && tfDynamicEvaluation1.getValue().trim().length() > 0) { evalobj.setCustomLbl1(tfDynamicEvaluation1.getCaption()); evalobj.setCustomValue1(tfDynamicEvaluation1.getValue()); } if (tfDynamicEvaluation2.getValue() != null && tfDynamicEvaluation2.getValue().trim().length() > 0) { evalobj.setCustomValue2(tfDynamicEvaluation2.getCaption()); evalobj.setCustomValue2(tfDynamicEvaluation2.getValue()); } beanEvaluation.saveorUpdateEvalDetails(evalobj); uiflowdata.setEvalDtls(evalobj); try { saveOwnerDetails(); } catch (Exception e) { } try { saveAssetDetails(); } catch (Exception e) { } try { saveNormalDocuments(); } catch (Exception e) { } try { saveLegalDocuments(); } catch (Exception e) { } try { saveAdjoinPropertyDetails(); } catch (Exception e) { } try { saveDimensionValues(); } catch (Exception e) { logger.info("Error-->" + e); } try { saveMatchingBoundaries(); } catch (Exception e) { } try { saveNoofRooms(); } catch (Exception e) { } try { saveNoofFloors(); } catch (Exception e) { } try { saveTenureOccupayDetails(); } catch (Exception e) { } try { saveAreaDetailsofProperty(); } catch (Exception e) { } try { saveDetailsofApartment(); } catch (Exception e) { } try { saveFlatValuation(); } catch (Exception e) { } try { savePlanApprovalDetails(); } catch (Exception e) { } try { saveBuildSpecDetails(); } catch (Exception e) { } try { saveConstValuationDetails(); } catch (Exception e) { } try { savePropertyValueDetails(); } catch (Exception e) { } try { uiflowdata.setPropDesc((String) slPropertyDesc.getValue()); uiflowdata.setPropertyAddress(tfPropertyAddress.getValue()); uiflowdata.setEvalnumber(tfEvaluationNumber.getValue()); uiflowdata.setBankBranch((String) slBankBranch.getValue()); uiflowdata.setCustomername(tfCustomerName.getValue()); uiflowdata .setGuidelinevalue(XMLUtil.IndianFormat(new BigDecimal(tfCostOfConstAsAtSite.getValue()))); uiflowdata.setMarketValue(XMLUtil.IndianFormat(new BigDecimal(tfCostOfConstAsPerAgree.getValue()))); if (dfDateofValuation.getValue() != null) { SimpleDateFormat dt1 = new SimpleDateFormat("dd-MMM-yyyy"); uiflowdata.setInspectionDate(dt1.format(dfDateofValuation.getValue())); } uiflowdata.setPropDesc((String) slPropertyDesc.getValue()); String numberOnly = tfCostOfConstAsAtSite.getValue().replaceAll("[^\\d.]", ""); uiflowdata.setAmountInWords(beanEvaluation.getAmountInWords(numberOnly)); //Bill } catch (Exception e) { } evalNumber = tfEvaluationNumber.getValue(); customer = tfCustomerName.getValue(); propertyType = "FLAT"; ByteArrayOutputStream recvstram = XMLUtil.doMarshall(uiflowdata); XMLUtil.getWordDocument(recvstram, evalNumber + "_" + customer + "_" + propertyType, strXslFile); if (tfEvaluationNumber.isValid() && slBankBranch.isValid() && tfEvaluationPurpose.isValid() && dfDateofValuation.isValid()) { if (count == 0) { beanEvaluation.saveorUpdateEvalDetails(evalobj); valid = true; } lblNotificationIcon.setIcon(new ThemeResource("img/success_small.png")); lblSaveNotification.setValue(ApplicationConstants.saveMsg); } if (valid) { /*populateAndConfig(false); resetAllFieldsFields();*/ btnSave.setEnabled(false); } else { btnSave.setComponentError(new UserError("Form is invalid")); } } catch (Exception e) { lblNotificationIcon.setIcon(new ThemeResource("img/failure.png")); lblSaveNotification.setValue("Save failed, please check the data and try again "); logger.info("Error on SaveApproveReject Status function--->" + e); } }
From source file:com.haulmont.cuba.web.gui.components.WebAbstractComponent.java
License:Apache License
protected void setValidationError(String errorMessage) { if (getComposition() instanceof AbstractComponent) { AbstractComponent composition = (AbstractComponent) getComposition(); if (errorMessage == null) { composition.setComponentError(null); } else {//ww w .ja v a2 s . c o m composition.setComponentError(new UserError(errorMessage)); } } }
From source file:com.haulmont.cuba.web.gui.components.WebTimeField.java
License:Apache License
@Override protected ItemWrapper createDatasourceWrapper(Datasource datasource, Collection<MetaPropertyPath> propertyPaths) { return new ItemWrapper(datasource, datasource.getMetaClass(), propertyPaths) { private static final long serialVersionUID = 1729450322469573679L; @Override/*from w ww .j a va 2s .c o m*/ protected PropertyWrapper createPropertyWrapper(Object item, MetaPropertyPath propertyPath) { return new PropertyWrapper(item, propertyPath) { private static final long serialVersionUID = -4481934193197224070L; @Override public String getFormattedValue() { Object value = this.getValue(); if (value instanceof Date) { SimpleDateFormat sdf = new SimpleDateFormat(timeFormat); return sdf.format(value); } return super.getFormattedValue(); } @Override protected Object valueOf(Object newValue) throws Converter.ConversionException { if (newValue instanceof String) { if (StringUtils.isNotEmpty((String) newValue) && !newValue.equals(placeholder)) { try { SimpleDateFormat sdf = new SimpleDateFormat(timeFormat); Date date = sdf.parse((String) newValue); if (component.getComponentError() != null) { component.setComponentError(null); } return date; } catch (Exception e) { LoggerFactory.getLogger(WebTimeField.class) .debug("Unable to parse value of component " + getId() + "\n" + e.getMessage()); component.setComponentError(new UserError("Invalid value")); return null; } } else return null; } else return newValue; } }; } }; }
From source file:com.lst.deploymentautomation.vaadin.util.Utils.java
License:Open Source License
/** * Shows (or hides, if msg is null) localized error message on the given component. * @param component/*from w w w. j a va 2 s . c o m*/ * @param msg * @param args */ public static void setComponentError(AbstractComponent component, String msg, Object... args) { if (msg == null) { component.setComponentError(null); } else { String localizedMsg = getLocalizedString(component.getUI().getLocale(), msg, args); component.setComponentError(new UserError(localizedMsg)); } }
From source file:com.naoset.framework.frontend.component.profile.CustomerPanelView.java
private Component builtData() { FormLayout details = new FormLayout(); details.addStyleName(ValoTheme.FORMLAYOUT_LIGHT); code = new TextField("First Name"); details.addComponent(code);// w ww.j a v a 2s . c o m name = new TextField("Last Name"); details.addComponent(name); sexField = new OptionGroup("Sex"); sexField.addItem(Boolean.FALSE); sexField.setItemCaption(Boolean.FALSE, "Female"); sexField.addItem(Boolean.TRUE); sexField.setItemCaption(Boolean.TRUE, "Male"); sexField.addStyleName("horizontal"); details.addComponent(sexField); // Label section = new Label("Contact Info"); // section.addStyleName(ValoTheme.LABEL_H4); // section.addStyleName(ValoTheme.LABEL_COLORED); // details.addComponent(section); emailField = new TextField("Email"); emailField.setWidth("100%"); emailField.setRequired(true); emailField.setNullRepresentation(""); details.addComponent(emailField); locationField = new TextField("Direccin"); locationField.setWidth("100%"); locationField.setNullRepresentation(""); locationField.setComponentError(new UserError("This address doesn't exist")); details.addComponent(locationField); phoneField = new TextField("Telefono"); phoneField.setWidth("100%"); phoneField.setNullRepresentation(""); details.addComponent(phoneField); details.addComponent(buildSpecies()); return details; }
From source file:com.rex.components.valo.ComboBoxes.java
License:Apache License
public ComboBoxes() { setMargin(true);//from ww w.j a va2 s . co m Label h1 = new Label("Combo Boxes"); h1.addStyleName("h1"); addComponent(h1); HorizontalLayout row = new HorizontalLayout(); row.addStyleName("wrapping"); row.setSpacing(true); addComponent(row); ComboBox combo = new ComboBox("Normal"); combo.setInputPrompt("You can type here"); combo.setContainerDataSource(ReportEngineUI.generateContainer(200, false)); combo.setNullSelectionAllowed(false); combo.select(combo.getItemIds().iterator().next()); combo.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY); combo.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY); combo.setItemIcon(combo.getItemIds().iterator().next(), new ThemeResource("../runo/icons/16/document.png")); row.addComponent(combo); CssLayout group = new CssLayout(); group.setCaption("Grouped with a Button"); group.addStyleName("v-component-group"); row.addComponent(group); combo = new ComboBox(); combo.setInputPrompt("You can type here"); combo.setContainerDataSource(ReportEngineUI.generateContainer(200, false)); combo.setNullSelectionAllowed(false); combo.select(combo.getItemIds().iterator().next()); combo.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY); combo.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY); combo.setWidth("240px"); group.addComponent(combo); Button today = new Button("Do It"); group.addComponent(today); combo = new ComboBox("Explicit size"); combo.setInputPrompt("You can type here"); combo.addItem("Option One"); combo.addItem("Option Two"); combo.addItem("Option Three"); combo.setWidth("260px"); combo.setHeight("60px"); row.addComponent(combo); combo = new ComboBox("No text input allowed"); combo.setInputPrompt("You can click here"); combo.addItem("Option One"); combo.addItem("Option Two"); combo.addItem("Option Three"); combo.setTextInputAllowed(false); combo.setNullSelectionAllowed(false); combo.select("Option One"); row.addComponent(combo); combo = new ComboBox("Error"); combo.setInputPrompt("You can type here"); combo.addItem("Option One"); combo.addItem("Option Two"); combo.addItem("Option Three"); combo.setNullSelectionAllowed(false); combo.select("Option One"); combo.setComponentError(new UserError("Fix it, now!")); row.addComponent(combo); combo = new ComboBox("Error, borderless"); combo.setInputPrompt("You can type here"); combo.addItem("Option One"); combo.addItem("Option Two"); combo.addItem("Option Three"); combo.setNullSelectionAllowed(false); combo.select("Option One"); combo.setComponentError(new UserError("Fix it, now!")); combo.addStyleName("borderless"); row.addComponent(combo); combo = new ComboBox("Disabled"); combo.setInputPrompt("You can't type here"); combo.addItem("Option One"); combo.addItem("Option Two"); combo.addItem("Option Three"); combo.setEnabled(false); row.addComponent(combo); combo = new ComboBox("Custom color"); combo.setInputPrompt("You can type here"); combo.setContainerDataSource(ReportEngineUI.generateContainer(200, false)); combo.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY); combo.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY); combo.addStyleName("color1"); row.addComponent(combo); combo = new ComboBox("Custom color"); combo.setInputPrompt("You can type here"); combo.setContainerDataSource(ReportEngineUI.generateContainer(200, false)); combo.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY); combo.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY); combo.addStyleName("color2"); row.addComponent(combo); combo = new ComboBox("Custom color"); combo.setInputPrompt("You can type here"); combo.setContainerDataSource(ReportEngineUI.generateContainer(200, false)); combo.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY); combo.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY); combo.addStyleName("color3"); row.addComponent(combo); combo = new ComboBox("Small"); combo.setInputPrompt("You can type here"); combo.setContainerDataSource(ReportEngineUI.generateContainer(200, false)); combo.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY); combo.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY); combo.addStyleName("small"); row.addComponent(combo); combo = new ComboBox("Large"); combo.setInputPrompt("You can type here"); combo.setContainerDataSource(ReportEngineUI.generateContainer(200, false)); combo.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY); combo.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY); combo.addStyleName("large"); row.addComponent(combo); combo = new ComboBox("Borderless"); combo.setInputPrompt("You can type here"); combo.addItem("Option One"); combo.addItem("Option Two"); combo.addItem("Option Three"); combo.addStyleName("borderless"); row.addComponent(combo); combo = new ComboBox("Tiny"); combo.setInputPrompt("You can type here"); combo.setContainerDataSource(ReportEngineUI.generateContainer(200, false)); combo.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY); combo.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY); combo.addStyleName("tiny"); row.addComponent(combo); combo = new ComboBox("Huge"); combo.setInputPrompt("You can type here"); combo.setContainerDataSource(ReportEngineUI.generateContainer(200, false)); combo.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY); combo.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY); combo.addStyleName("huge"); row.addComponent(combo); }
From source file:com.skysql.manager.ui.GeneralSettings.java
License:Open Source License
/** * Time layout./*from w ww . j a v a2s . c o m*/ * * @return the vertical layout */ private VerticalLayout timeLayout() { VerticalLayout layout = new VerticalLayout(); layout.setWidth("100%"); layout.setSpacing(true); layout.setMargin(new MarginInfo(false, true, false, true)); HorizontalLayout titleLayout = new HorizontalLayout(); titleLayout.setSpacing(true); layout.addComponent(titleLayout); final Label title = new Label("<h3>Date & Time Presentation</h3>", ContentMode.HTML); title.setSizeUndefined(); titleLayout.addComponent(title); Embedded info = new Embedded(null, new ThemeResource("img/info.png")); info.addStyleName("infoButton"); info.setDescription( "Determines if date & time stamps are displayed in the originally recorded format or adjusted to the local timezone.<br/>The format can be customized by using the following Java 6 SimpleDateFormat patterns:" + "</blockquote>" + " <table border=0 cellspacing=3 cellpadding=0 summary=\"Chart shows pattern letters, date/time component, presentation, and examples.\">\n" + " <tr bgcolor=\"#ccccff\">\n" + " <th align=left>Letter\n" + " <th align=left>Date or Time Component\n" + " <th align=left>Presentation\n" + " <th align=left>Examples\n" + " <tr>\n" + " <td><code>G</code>\n" + " <td>Era designator\n" + " <td><a href=\"#text\">Text</a>\n" + " <td><code>AD</code>\n" + " <tr bgcolor=\"#eeeeff\">\n" + " <td><code>y</code>\n" + " <td>Year\n" + " <td><a href=\"#year\">Year</a>\n" + " <td><code>1996</code>; <code>96</code>\n" + " <tr>\n" + " <td><code>M</code>\n" + " <td>Month in year\n" + " <td><a href=\"#month\">Month</a>\n" + " <td><code>July</code>; <code>Jul</code>; <code>07</code>\n" + " <tr bgcolor=\"#eeeeff\">\n" + " <td><code>w</code>\n" + " <td>Week in year\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>27</code>\n" + " <tr>\n" + " <td><code>W</code>\n" + " <td>Week in month\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>2</code>\n" + " <tr bgcolor=\"#eeeeff\">\n" + " <td><code>D</code>\n" + " <td>Day in year\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>189</code>\n" + " <tr>\n" + " <td><code>d</code>\n" + " <td>Day in month\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>10</code>\n" + " <tr bgcolor=\"#eeeeff\">\n" + " <td><code>F</code>\n" + " <td>Day of week in month\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>2</code>\n" + " <tr>\n" + " <td><code>E</code>\n" + " <td>Day in week\n" + " <td><a href=\"#text\">Text</a>\n" + " <td><code>Tuesday</code>; <code>Tue</code>\n" + " <tr bgcolor=\"#eeeeff\">\n" + " <td><code>a</code>\n" + " <td>Am/pm marker\n" + " <td><a href=\"#text\">Text</a>\n" + " <td><code>PM</code>\n" + " <tr>\n" + " <td><code>H</code>\n" + " <td>Hour in day (0-23)\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>0</code>\n" + " <tr bgcolor=\"#eeeeff\">\n" + " <td><code>k</code>\n" + " <td>Hour in day (1-24)\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>24</code>\n" + " <tr>\n" + " <td><code>K</code>\n" + " <td>Hour in am/pm (0-11)\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>0</code>\n" + " <tr bgcolor=\"#eeeeff\">\n" + " <td><code>h</code>\n" + " <td>Hour in am/pm (1-12)\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>12</code>\n" + " <tr>\n" + " <td><code>m</code>\n" + " <td>Minute in hour\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>30</code>\n" + " <tr bgcolor=\"#eeeeff\">\n" + " <td><code>s</code>\n" + " <td>Second in minute\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>55</code>\n" + " <tr>\n" + " <td><code>S</code>\n" + " <td>Millisecond\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>978</code>\n" + " <tr bgcolor=\"#eeeeff\">\n" + " <td><code>z</code>\n" + " <td>Time zone\n" + " <td><a href=\"#timezone\">General time zone</a>\n" + " <td><code>Pacific Standard Time</code>; <code>PST</code>; <code>GMT-08:00</code>\n" + " <tr>\n" + " <td><code>Z</code>\n" + " <td>Time zone\n" + " <td><a href=\"#rfc822timezone\">RFC 822 time zone</a>\n" + " <td><code>-0800</code>\n" + " </table>\n" + " </blockquote>\n" + ""); titleLayout.addComponent(info); titleLayout.setComponentAlignment(info, Alignment.MIDDLE_CENTER); final DateConversion dateConversion = VaadinSession.getCurrent().getAttribute(DateConversion.class); OptionGroup option = new OptionGroup("Display options"); option.addItem(false); option.setItemCaption(false, "Show time in UTC/GMT"); option.addItem(true); option.setItemCaption(true, "Adjust to local timezone (" + dateConversion.getClientTZname() + ")"); String propertyTimeAdjust = userObject.getProperty(UserObject.PROPERTY_TIME_ADJUST); option.select(propertyTimeAdjust == null ? DEFAULT_TIME_ADJUST : Boolean.valueOf(propertyTimeAdjust)); option.setNullSelectionAllowed(false); option.setHtmlContentAllowed(true); option.setImmediate(true); layout.addComponent(option); final HorizontalLayout defaultLayout = new HorizontalLayout(); defaultLayout.setSpacing(true); layout.addComponent(defaultLayout); final Form form = new Form(); form.setFooter(null); final TextField timeFormat = new TextField("Format"); form.addField("timeFormat", timeFormat); defaultLayout.addComponent(form); option.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { boolean value = (Boolean) event.getProperty().getValue(); dateConversion.setAdjustedToLocal(value); userObject.setProperty(UserObject.PROPERTY_TIME_ADJUST, String.valueOf(value)); settingsDialog.setRefresh(true); if (value == false) { timeFormat.removeAllValidators(); timeFormat.setComponentError(null); form.setComponentError(null); form.setValidationVisible(false); settingsDialog.setClose(true); } else { timeFormat.addValidator(new TimeFormatValidator()); timeFormat.setInputPrompt(DateConversion.DEFAULT_TIME_FORMAT); //timeFormat.setClickShortcut(KeyCode.ENTER); } } }); String propertyTimeFormat = userObject.getProperty(UserObject.PROPERTY_TIME_FORMAT); propertyTimeFormat = (propertyTimeFormat == null ? DateConversion.DEFAULT_TIME_FORMAT : String.valueOf(propertyTimeFormat)); timeFormat.setColumns(16); timeFormat.setValue(propertyTimeFormat); timeFormat.setImmediate(true); timeFormat.setRequired(true); timeFormat.setRequiredError("Format cannot be empty."); timeFormat.addValidator(new TimeFormatValidator()); timeFormat.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); try { form.setComponentError(null); form.commit(); timeFormat.setComponentError(null); form.setValidationVisible(false); dateConversion.setFormat(value); userObject.setProperty(UserObject.PROPERTY_TIME_FORMAT, value); settingsDialog.setClose(true); settingsDialog.setRefresh(true); } catch (InvalidValueException e) { settingsDialog.setClose(false); timeFormat.setComponentError(new UserError("Invalid Format (Java SimpleDateFormat).")); timeFormat.focus(); } } }); Button defaultButton = new Button("Restore Default"); defaultLayout.addComponent(defaultButton); defaultLayout.setComponentAlignment(defaultButton, Alignment.MIDDLE_LEFT); defaultButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(Button.ClickEvent event) { timeFormat.setValue(DateConversion.DEFAULT_TIME_FORMAT); } }); return layout; }
From source file:com.snowy.NewUserSubWindow.java
public void build() { //setClosable(false); setModal(true);// w w w.jav a 2 s . co m setResizable(false); setResponsive(true); setDraggable(false); FormLayout fl = new FormLayout(); fl.setMargin(true); //fl.setSizeFull(); fl.setSizeUndefined(); fl.setSpacing(true); TextField uname = new TextField("Username"); uname.setRequired(true); //uname.addValidator(null); fl.addComponent(uname); TextField email = new TextField("Email"); email.setRequired(true); email.addValidator(new EmailValidator("A Valid Email is Required")); fl.addComponent(email); PasswordField pf1 = new PasswordField("Password"); pf1.setRequired(true); pf1.addValidator(new StringLengthValidator("Password must be between 8 and 60 characters", 8, 60, false)); fl.addComponent(pf1); PasswordField pf2 = new PasswordField("Confirm Password"); pf2.setRequired(true); pf2.addValidator((Object value) -> { if (!pf2.getValue().equals(pf1.getValue())) { throw new InvalidValueException("Passwords Must Match"); } }); //pf2.setImmediate(true); fl.addComponent(pf2); Button b = new Button("Submit"); b.addClickListener((Button.ClickEvent e) -> { if (uname.isValid() && email.isValid() && pf1.isValid() && pf2.isValid()) { String result = d.createUser(uname.getValue(), pf2.getValue(), email.getValue()); if (result.equals("Creation Sucess")) { fl.removeAllComponents(); fl.addComponent(new Label("User Created Sucessfully")); fl.addComponent(new Button("Close", (ee) -> { this.close(); })); } else { Notification.show(result); } } else { b.setComponentError(new UserError("Issues with required fields")); } //d.close(); }); fl.addComponent(b); setContent(fl); }
From source file:com.squadd.views.LoginView.java
@PostConstruct private void configureComponents() { login = new Button("Sign in"); register = new Button("Register"); loginUI = new LoginUI(login, register, false); addComponents(loginUI);/* ww w .j av a 2 s . co m*/ Button.ClickListener log = new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (loginUI.getUsername().getValue().isEmpty()) { loginUI.getUsername().setComponentError(new UserError("Login field must not be empty")); } else if (loginUI.getPassword().getValue().isEmpty()) { loginUI.getPassword().setComponentError(new UserError("Password field must not be empty")); } else { if (Authorizator.successAuthorization(loginUI, contact)) { Notification.show("Welcome to the squadd!", Notification.Type.HUMANIZED_MESSAGE); getUI().getNavigator().navigateTo(UserPageView.NAME); } else { Notification.show("Wrong login/password", Notification.Type.ERROR_MESSAGE); } } } }; Button.ClickListener reg = new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { try { getUI().getNavigator().navigateTo(RegisterView.name); } catch (Exception e) { System.out.println(e.getMessage()); } } }; login.addClickListener(log); register.addClickListener(reg); }
From source file:com.squadd.views.RegisterView.java
private boolean noErrorsOnPage() { if (!mainInfo.getPassword().getValue().equals(mainInfo.getConfirmed().getValue())) { mainInfo.getConfirmed().setComponentError(new UserError("Please confirm password")); errorMessage = "Password and Confirm fields must be equal"; return false; } else if (mainInfo.getLogin().getValue().isEmpty()) { mainInfo.getLogin().setComponentError(new UserError("Login field must not be empty")); errorMessage = "Login field must not be empty"; return false; } else if (mainInfo.getPassword().getValue().isEmpty()) { mainInfo.getPassword().setComponentError(new UserError("Please enter the password")); errorMessage = "Please enter the password"; return false; } else if (!validLogin()) { mainInfo.getLogin().setComponentError(new UserError("Please enter a valid email")); errorMessage = "Please enter a valid email\n" + "For example:123@gmail.com"; return false; }//from w w w . ja va 2 s .c o m return true; }