public Field createField(Item item, Object propertyId, Component uiContext) { // Identify the fields by their Property ID. String pid = (String) propertyId; if ("userName".equals(pid)) { TextField field = new TextField("Username (Email)"); field.setRequired(true); field.setRequiredError("Please supply a username"); field.addValidator(new EmailValidator("Username must be an email address")); return field; } else if ("password".equals(pid)) { PasswordField field = new PasswordField("Password"); field.setRequired(true); field.setRequiredError("Please supply a password"); field.addValidator(new StringLengthValidator(VAL_PASSWD_LEN_MESSAGE, 5, 999, false)); field.addValidator(new NoWhiteSpaceValidator(VAL_PASSWD_TXT_MESSAGE)); return field; } else if ("confirmPassword".equals(pid)) { PasswordField field = new PasswordField("Confirm Password"); field.setRequired(true); field.setRequiredError("Please confirm your password"); field.addValidator(new StringLengthValidator(VAL_PASSWD_LEN_MESSAGE, 5, 999, false)); field.addValidator(new NoWhiteSpaceValidator(VAL_PASSWD_TXT_MESSAGE)); return field; } return null; // Invalid field (property) name. }
@AutoGenerated private HorizontalLayout buildConfirmDiv() { // common part: create layout confirmDiv = new HorizontalLayout(); confirmDiv.setImmediate(false); confirmDiv.setWidth("100.0%"); confirmDiv.setHeight("100.0%"); confirmDiv.setMargin(false); // confirmLabel confirmLabel = new Label(); confirmLabel.setImmediate(false); confirmLabel.setWidth("52px"); confirmLabel.setHeight("-1px"); confirmLabel.setValue("Confirm:"); confirmDiv.addComponent(confirmLabel); confirmDiv.setComponentAlignment(confirmLabel, new Alignment(9)); // passwordConfirm passwordConfirm = new PasswordField(); passwordConfirm.setCaption("Need confirm password:"******"195px"); passwordConfirm.setHeight("20px"); passwordConfirm.setRequired(true); confirmDiv.addComponent(passwordConfirm); confirmDiv.setExpandRatio(passwordConfirm, 1.0f); confirmDiv.setComponentAlignment(passwordConfirm, new Alignment(34)); return confirmDiv; }
@AutoGenerated private HorizontalLayout buildPasswordDiv() { // common part: create layout passwordDiv = new HorizontalLayout(); passwordDiv.setImmediate(false); passwordDiv.setDescription("Your password"); passwordDiv.setWidth("291px"); passwordDiv.setHeight("34px"); passwordDiv.setMargin(false); // passwordLabel passwordLabel = new Label(); passwordLabel.setImmediate(false); passwordLabel.setWidth("80px"); passwordLabel.setHeight("20px"); passwordLabel.setValue("Password:"******"Need Password"); passwordField.setImmediate(false); passwordField.setWidth("197px"); passwordField.setHeight("20px"); passwordField.setRequired(true); passwordDiv.addComponent(passwordField); passwordDiv.setComponentAlignment(passwordField, new Alignment(34)); return passwordDiv; }
public StartView() { setSizeFull(); setMargin(true); // Create a panel called login Panel panel = new Panel("Login"); panel.setSizeUndefined(); // Shrink to fit content addComponent(panel); setComponentAlignment(panel, Alignment.MIDDLE_CENTER); // Create the content FormLayout content = new FormLayout(); username.setWidth("300px"); username.setRequired(true); username.setInputPrompt("Your username(eg. [email protected])"); content.addComponent(username); password.setWidth("300px"); password.setRequired(true); content.addComponent(password); HorizontalLayout buttonArea = new HorizontalLayout(); buttonArea.setSizeFull(); Button submit = new Button("Submit"); Button clear = new Button("Clear"); clear.addClickListener( new Button.ClickListener() { public void buttonClick(ClickEvent event) { username.setValue(""); password.setValue(""); } }); submit.addClickListener( new Button.ClickListener() { public void buttonClick(ClickEvent event) { checkDatabase(username.getValue(), password.getValue()); } }); buttonArea.addComponent(clear); buttonArea.addComponent(submit); content.addComponent(buttonArea); content.setSizeFull(); content.setMargin(true); panel.setContent(content); }
public SimpleLoginView() { setSizeFull(); // Create the user input field userTextField = new TextField("User name: "); userTextField.setWidth("300px"); userTextField.setRequired(true); userTextField.setInputPrompt("Your username (eg. user1)"); userTextField.addValidator(new LoginValidator()); userTextField.setInvalidAllowed(false); // Create the password input field passwordField = new PasswordField("Password:"******"300px"); passwordField.setRequired(true); passwordField.addValidator(new PasswordValidator()); passwordField.setValue(""); passwordField.setNullRepresentation(""); // Create login button loginButton = new Button("Login", this); // Add all to a panel VerticalLayout fields = new VerticalLayout(userTextField, passwordField, loginButton); fields.setCaption("Please login to access the application. (user1/password)"); fields.setSpacing(true); fields.setMargin(new MarginInfo(true, true, true, false)); fields.setSizeUndefined(); // The view root layout VerticalLayout viewLayout = new VerticalLayout(fields); viewLayout.setSizeFull(); viewLayout.setComponentAlignment(fields, Alignment.MIDDLE_CENTER); viewLayout.setStyleName(Reindeer.LAYOUT_BLUE); setCompositionRoot(viewLayout); }
private void buildview() { // TODO Auto-generated method stub adnurse.setCaption("Add Nurse"); adnurse.getLayout().addComponent(SSN); SSN.setRequired(true); Validator ssnValidator = new RegexpValidator("[0-9]{6}-[0-9]{3}[0-9a-zA-Z]", "SSN must be in the form 123456-123X."); SSN.addValidator(ssnValidator); adnurse.getLayout().addComponent(Fname); Fname.setRequired(true); adnurse.getLayout().addComponent(Lname); Lname.setRequired(true); adnurse.getLayout().addComponent(Email); Email.addValidator(new EmailValidator("Invalid Email Address")); adnurse.getLayout().addComponent(Phone); adnurse.getLayout().addComponent(Password); Password.setRequired(true); adnurse.getLayout().addComponent(P2); P2.setRequired(true); adnurse.setFooter(new VerticalLayout()); HorizontalLayout bar = new HorizontalLayout(); adnurse.getFooter().addComponent(bar); save.addListener( new ClickListener() { public void buttonClick(ClickEvent event) { // TODO Auto-generated method stub if (SSN.isValid() == false) { // getWindow().showNotification("INCORRECT SSN"); getWindow().showNotification("Incorrect SSN", Window.Notification.TYPE_ERROR_MESSAGE); } if (Fname.isValid() == false) { // fname= Fname.getValue().toString(); // Fname.setValue(""); getWindow() .showNotification("Enter first name", Window.Notification.TYPE_ERROR_MESSAGE); } if (Lname.isValid() == false) { getWindow() .showNotification("Enter Last name", Window.Notification.TYPE_ERROR_MESSAGE); } // fname= Fname.getValue().toString(); // lname = Lname.getValue().toString(); // email =Email.getValue().toString(); // phone = Phone.getValue().toString(); if (Password.getValue().toString().equals(P2.getValue().toString())) { if (Password.isValid()) { password = Password.getValue().toString(); // Password.setValue(""); // P2.setValue(""); } else { Password.setValue(""); P2.setValue(""); getWindow() .showNotification("Invalid Password", Window.Notification.TYPE_ERROR_MESSAGE); } } else { Password.setValue(""); P2.setValue(""); getWindow() .showNotification( "Password Doesn't Match", Window.Notification.TYPE_ERROR_MESSAGE); } // password = Password.getValue().toString(); // pt.addnurse(ssn,fname,lname,email,phone,password); if (SSN.isValid() == true && Fname.isValid() == true && Lname.isValid() == true && Password.isValid() == true && Password.getValue().toString().equals(P2.getValue().toString()) == true) { ssn = SSN.getValue().toString(); fname = Fname.getValue().toString(); lname = Lname.getValue().toString(); email = Email.getValue().toString(); phone = Phone.getValue().toString(); password = Password.getValue().toString(); pt.addnurse(ssn, fname, lname, email, phone, password); SSN.setValue(""); Fname.setValue(""); Lname.setValue(""); Password.setValue(""); P2.setValue(""); Email.setValue(""); Phone.setValue(""); getWindow() .showNotification( "Welcome To Smart Dosing", Window.Notification.TYPE_HUMANIZED_MESSAGE); } } }); cancel.addListener( new ClickListener() { public void buttonClick(ClickEvent event) { // TODO Auto-generated method stub close(); } }); Button close = new Button( null, new ClickListener() { public void buttonClick(ClickEvent event) { event .getButton() .getWindow() .getParent() .removeWindow(event.getButton().getWindow()); } }); close.setIcon(new ThemeResource("logout.png")); navigationView.setRightComponent(close); save.setWidth("40%"); cancel.setWidth("40%"); bar.addComponent(save); bar.addComponent(cancel); adn.addComponent(adnurse); setContent(navigationView); }