You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ma...@apache.org on 2012/05/09 11:35:39 UTC
svn commit: r1336030 - in /james/hupa/trunk/client/src/main:
java/org/apache/hupa/client/HupaCSS.java
java/org/apache/hupa/client/mvp/LoginView.java webapp/Hupa.css
webapp/Hupa.html
Author: manolo
Date: Wed May 9 09:35:38 2012
New Revision: 1336030
URL: http://svn.apache.org/viewvc?rev=1336030&view=rev
Log:
Make the login page compatible with the browser save password feature, and replace cobogw buttons by css-stiled ones in it
Modified:
james/hupa/trunk/client/src/main/java/org/apache/hupa/client/HupaCSS.java
james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/LoginView.java
james/hupa/trunk/client/src/main/webapp/Hupa.css
james/hupa/trunk/client/src/main/webapp/Hupa.html
Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/HupaCSS.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/HupaCSS.java?rev=1336030&r1=1336029&r2=1336030&view=diff
==============================================================================
--- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/HupaCSS.java (original)
+++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/HupaCSS.java Wed May 9 09:35:38 2012
@@ -77,4 +77,6 @@ public class HupaCSS extends WidgetsCSS
public static final String C_dialog = "hupa-dialog-box";
public static final String C_validate = "hupa-validate-error";
+
+ public static final String C_button = "hupa-button";
}
Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/LoginView.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/LoginView.java?rev=1336030&r1=1336029&r2=1336030&view=diff
==============================================================================
--- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/LoginView.java (original)
+++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/LoginView.java Wed May 9 09:35:38 2012
@@ -23,18 +23,23 @@ import org.apache.hupa.client.HupaCSS;
import org.apache.hupa.client.HupaConstants;
import org.apache.hupa.widgets.ui.Loading;
import org.apache.hupa.widgets.ui.RndPanel;
-import org.cobogw.gwt.user.client.ui.Button;
-import org.cobogw.gwt.user.client.ui.ButtonBar;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
+import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Focusable;
+import com.google.gwt.user.client.ui.FormPanel;
+import com.google.gwt.user.client.ui.FormPanel.SubmitEvent;
import com.google.gwt.user.client.ui.HasValue;
+import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.PasswordTextBox;
+import com.google.gwt.user.client.ui.SubmitButton;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
@@ -46,38 +51,52 @@ import com.google.inject.Inject;
*/
public class LoginView extends Composite implements KeyUpHandler,LoginPresenter.Display{
- private Button loginButton;
+ private Button loginButton = new Button();
+ private SubmitButton submitButton;
private Button resetButton;
- private TextBox usernameTextBox = new TextBox();
- private PasswordTextBox passwordTextBox = new PasswordTextBox();
private Loading loading;
+
+ // We wrap login/password boxes with a form which must be in the html document,
+ // in this way, the browser knows that we are sending a login form and
+ // offers the save password dialog to the user
+ private TextBox usernameTextBox = TextBox.wrap(DOM.getElementById("email"));
+ private PasswordTextBox passwordTextBox = PasswordTextBox.wrap(DOM.getElementById("password"));
+ // wrap the form after inputs so as they are in the dom when are wrapped
+ final private FormPanel formPanel = FormPanel.wrap(DOM.getElementById("loginForm"), true);
+
@Inject
public LoginView(HupaConstants constants) {
VerticalPanel mainContainer = new VerticalPanel();
RndPanel rPanel = new RndPanel();
- FlexTable formPanel = new FlexTable();
- ButtonBar buttonBar = new ButtonBar();
- loginButton = new Button(constants.loginButton());
- resetButton = new Button(constants.resetButton());
+ FlexTable flexTable = new FlexTable();
+ Panel buttonBar = new FlowPanel();
+ submitButton = new SubmitButton(constants.loginButton());
+ resetButton = new Button(constants.resetButton());
+ submitButton.getElement().setClassName(HupaCSS.C_button);
+ resetButton.getElement().setClassName(HupaCSS.C_button);
+ submitButton.getElement().setClassName(resetButton.getElement().getClassName());
loading = new Loading(constants.loading());
mainContainer.setStyleName(HupaCSS.C_login_container);
- formPanel.addStyleName(HupaCSS.C_login_form);
+ flexTable.addStyleName(HupaCSS.C_login_form);
usernameTextBox.addStyleName(HupaCSS.C_login_box);
+ usernameTextBox.setName("user");
passwordTextBox.addStyleName(HupaCSS.C_login_box);
+ usernameTextBox.setName("password");
- buttonBar.add(loginButton);
+ buttonBar.add(submitButton);
buttonBar.add(resetButton);
- formPanel.setText(0, 0, constants.usernameLabel());
- formPanel.setWidget(0, 1, usernameTextBox);
- formPanel.setText(1, 0, constants.passwordLabel());
- formPanel.setWidget(1, 1, passwordTextBox);
- formPanel.getFlexCellFormatter().setColSpan(2, 0, 2);
- formPanel.setWidget(2, 0, buttonBar);
+ flexTable.setText(0, 0, constants.usernameLabel());
+ flexTable.setWidget(0, 1, usernameTextBox);
+ flexTable.setText(1, 0, constants.passwordLabel());
+ flexTable.setWidget(1, 1, passwordTextBox);
+ flexTable.getFlexCellFormatter().setColSpan(2, 0, 2);
+ flexTable.setWidget(2, 0, buttonBar);
rPanel.add(formPanel);
+ formPanel.add(flexTable);
mainContainer.add(rPanel);
mainContainer.add(loading);
initWidget(mainContainer);
@@ -87,6 +106,19 @@ public class LoginView extends Composite
passwordTextBox.addKeyUpHandler(this);
loading.hide();
+
+ // The user submits the form so as the browser detect it and displays
+ // the save password dialog. Then we click on the hidden loginButton which
+ // stores the presenter clickHandler.
+ formPanel.addSubmitHandler(new FormPanel.SubmitHandler() {
+ public void onSubmit(SubmitEvent event) {
+ event.cancel();
+ loginButton.click();
+ }
+ });
+ // loginButton must be in the document to handle the click() method
+ mainContainer.add(loginButton);
+ loginButton.setVisible(false);
}
/*
@@ -101,7 +133,7 @@ public class LoginView extends Composite
if (event.getSource().equals(usernameTextBox)) {
passwordTextBox.setFocus(true);
} else if (event.getSource().equals(passwordTextBox)) {
- loginButton.click();
+ submitButton.click();
}
}
}
Modified: james/hupa/trunk/client/src/main/webapp/Hupa.css
URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/webapp/Hupa.css?rev=1336030&r1=1336029&r2=1336030&view=diff
==============================================================================
--- james/hupa/trunk/client/src/main/webapp/Hupa.css (original)
+++ james/hupa/trunk/client/src/main/webapp/Hupa.css Wed May 9 09:35:38 2012
@@ -351,7 +351,6 @@ table.hupa-contacts {
}
/**** HTML5 shadows and gradients ****/
-
body {
background: #eaeaea;
}
@@ -394,3 +393,37 @@ div.hupa-main {
* html .hupa-bottom {
filter: progid:DXImageTransform.Microsoft.Shadow(color='#666666', Direction=135, Strength=1);
}
+
+.hupa-button {
+ background: #FFFFFF;
+ background: -moz-linear-gradient(#FFFFFF, #EDEDED);
+ background: -webkit-linear-gradient(#FFFFFF, #EDEDED);
+ background: -o-linear-gradient(#FFFFFF, #EDEDED);
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#FFFFFF', endColorstr='#EDEDED',GradientType=0 );
+ border: 1px solid #B7B7B7;
+ color: #606060;
+ border-radius: 2em 2em 2em 2em;
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
+ cursor: pointer;
+ display: inline-block;
+ font: 10px;
+ margin: 0 2px;
+ outline: medium none;
+ padding: 2px 10px;
+ text-align: center;
+ text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
+ vertical-align: baseline;
+}
+.hupa-button:hover {
+ background: #ededed;
+ background: -moz-linear-gradient(#FFFFFF, #dcdcdc);
+ background: -webkit-linear-gradient(#FFFFFF, #dcdcdc);
+ background: -o-linear-gradient(#FFFFFF, #dcdcdc);
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#FFFFFF', endColorstr='#dcdcdc',GradientType=0 );
+}
+
+
+
+
+
+
Modified: james/hupa/trunk/client/src/main/webapp/Hupa.html
URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/webapp/Hupa.html?rev=1336030&r1=1336029&r2=1336030&view=diff
==============================================================================
--- james/hupa/trunk/client/src/main/webapp/Hupa.html (original)
+++ james/hupa/trunk/client/src/main/webapp/Hupa.html Wed May 9 09:35:38 2012
@@ -35,6 +35,9 @@
top: 50%;
left: 50%;
}
+ #login {
+ display: none;
+ }
</style>
</head>
@@ -48,6 +51,14 @@
<img src="images/hupa-spinning.gif">
</div>
+ <!-- We need this because passwords in forms rendered by js are not saved in browsers -->
+ <div id="login">
+ <form id="loginForm" action="hupa/hupa.nocache.js" method="post">
+ <input id="email" name="email" type="text">
+ <input id="password" name="password" type="password">
+ </form>
+ </div>
+
<!-- Necessary for history support -->
<iframe src="javascript:''" id="__gwt_historyFrame" style="width:0;height:0;border:0"></iframe>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org