diff options
author | Henri Sara <henri.sara@itmill.com> | 2010-10-26 09:45:51 +0000 |
---|---|---|
committer | Henri Sara <henri.sara@itmill.com> | 2010-10-26 09:45:51 +0000 |
commit | 0e5439f0bde42f3218100d562c45cac7c8813187 (patch) | |
tree | 6264f1dc1bbecd894a45e21209cd2fa7aeccbb81 | |
parent | b9cee52a319551ff66b5247420e7b1ea8207ca07 (diff) | |
download | vaadin-framework-0e5439f0bde42f3218100d562c45cac7c8813187.tar.gz vaadin-framework-0e5439f0bde42f3218100d562c45cac7c8813187.zip |
#5226 Changing LoginForm field captions: change and test
svn changeset:15710/svn branch:6.5
4 files changed, 126 insertions, 5 deletions
diff --git a/src/com/vaadin/ui/LoginForm.java b/src/com/vaadin/ui/LoginForm.java index a77fde1368..6c1edb8171 100644 --- a/src/com/vaadin/ui/LoginForm.java +++ b/src/com/vaadin/ui/LoginForm.java @@ -40,6 +40,10 @@ import com.vaadin.terminal.gwt.client.ApplicationConnection; */ public class LoginForm extends CustomComponent { + private String usernameCaption = "Username"; + private String passwordCaption = "Password"; + private String loginButtonCaption = "Login"; + private Embedded iframe = new Embedded(); private ApplicationResource loginPage = new ApplicationResource() { @@ -129,7 +133,6 @@ public class LoginForm extends CustomComponent { * @return byte array containing login page html */ protected byte[] getLoginHTML() { - String appUri = getApplication().getURL().toString() + getWindow().getName() + "/"; @@ -164,11 +167,16 @@ public class LoginForm extends CustomComponent { + "<iframe name='logintarget' style='width:0;height:0;" + "border:0;margin:0;padding:0;'></iframe>" + "<form id='loginf' target='logintarget' onkeypress=\"submitOnEnter(event)\" method=\"post\">" - + "<div>Username</div><div >" + + "<div>" + + usernameCaption + + "</div><div >" + "<input class='v-textfield' style='display:block;' type='text' name='username'></div>" - + "<div>Password</div>" + + "<div>" + + passwordCaption + + "</div>" + "<div><input class='v-textfield' style='display:block;' type='password' name='password'></div>" - + "<div><div onclick=\"document.forms[0].submit();\" tabindex=\"0\" class=\"v-button\" role=\"button\" ><span class=\"v-button-wrap\"><span class=\"v-button-caption\">Login</span></span></div></div></form></div>" + "</body></html>") + + "<div><div onclick=\"document.forms[0].submit();\" tabindex=\"0\" class=\"v-button\" role=\"button\" ><span class=\"v-button-wrap\"><span class=\"v-button-caption\">" + + loginButtonCaption + "</span></span></div></div></form></div>" + "</body></html>") .getBytes(); } @@ -292,4 +300,61 @@ public class LoginForm extends CustomComponent { } } + /** + * Returns the caption for the user name field. + * + * @return String + */ + public String getUsernameCaption() { + return usernameCaption; + } + + /** + * Sets the caption to show for the user name field. The caption cannot be + * changed after the form has been shown to the user. + * + * @param usernameCaption + */ + public void setUsernameCaption(String usernameCaption) { + this.usernameCaption = usernameCaption; + } + + /** + * Returns the caption for the password field. + * + * @return String + */ + public String getPasswordCaption() { + return passwordCaption; + } + + /** + * Sets the caption to show for the password field. The caption cannot be + * changed after the form has been shown to the user. + * + * @param passwordCaption + */ + public void setPasswordCaption(String passwordCaption) { + this.passwordCaption = passwordCaption; + } + + /** + * Returns the caption for the login button. + * + * @return String + */ + public String getLoginButtonCaption() { + return loginButtonCaption; + } + + /** + * Sets the caption (button text) to show for the login button. The caption + * cannot be changed after the form has been shown to the user. + * + * @param loginButtonCaption + */ + public void setLoginButtonCaption(String loginButtonCaption) { + this.loginButtonCaption = loginButtonCaption; + } + } diff --git a/tests/src/com/vaadin/tests/components/loginform/CustomizedLoginFormTest.html b/tests/src/com/vaadin/tests/components/loginform/CustomizedLoginFormTest.html new file mode 100644 index 0000000000..5a2a0d839a --- /dev/null +++ b/tests/src/com/vaadin/tests/components/loginform/CustomizedLoginFormTest.html @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="" /> +<title>CustomizedLoginFormTest</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">CustomizedLoginFormTest</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.loginform.CustomizedLoginFormTest?restartApplication</td> + <td></td> +</tr> +<tr> + <td>pause</td> + <td>300</td> + <td>300</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>french</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/tests/src/com/vaadin/tests/components/loginform/CustomizedLoginFormTest.java b/tests/src/com/vaadin/tests/components/loginform/CustomizedLoginFormTest.java new file mode 100644 index 0000000000..3fde281c20 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/loginform/CustomizedLoginFormTest.java @@ -0,0 +1,24 @@ +package com.vaadin.tests.components.loginform; + +public class CustomizedLoginFormTest extends LoginFormTest { + + @Override + protected void setup() { + super.setup(); + + loginForm.setUsernameCaption("Identifiant"); + loginForm.setPasswordCaption("Mot de passe"); + loginForm.setLoginButtonCaption("Se connecter"); + } + + @Override + protected String getDescription() { + return "Customization of the captions on the LoginForm component. Three login forms should be visible (undefined height, undefined width, defined height and width). Entering a username+password in a login form and clicking 'login' should replace the login form with a label telling the user name as password. Also a logout button should then be shown and pressing that takes the user back to the original screen with the LoginForm"; + } + + @Override + protected Integer getTicketNumber() { + return 5226; + } + +} diff --git a/tests/src/com/vaadin/tests/components/loginform/LoginFormTest.java b/tests/src/com/vaadin/tests/components/loginform/LoginFormTest.java index 761800de5a..bbc7d2ca7e 100644 --- a/tests/src/com/vaadin/tests/components/loginform/LoginFormTest.java +++ b/tests/src/com/vaadin/tests/components/loginform/LoginFormTest.java @@ -14,7 +14,7 @@ import com.vaadin.ui.VerticalLayout; public class LoginFormTest extends TestBase { private HorizontalLayout loginFormLayout; - private LoginForm loginForm; + protected LoginForm loginForm; @Override protected void setup() { |