com.vaadin.ui.
Class LoginForm
-
All Implemented Interfaces:
ContextClickEvent.ContextClickNotifier
,MethodEventSource
,ClientConnector
,Sizeable
,Connector
,Component
,HasComponents
,HasComponents.ComponentAttachDetachNotifier
,SingleComponentContainer
,Serializable
,Iterable<Component>
public class LoginForm extends AbstractSingleComponentContainer
Login form with auto-completion and auto-fill for all major browsers. You can derive from this class and implement the
createContent(com.vaadin.ui.TextField, com.vaadin.ui.PasswordField, com.vaadin.ui.Button)
method to build the layout using the text fields and login button that are passed to that method. The supplied components are specially treated so that they work with password managers.To customize the fields or to replace them with your own implementations, you can override
createUsernameField()
,createPasswordField()
andcreateLoginButton()
. These methods are called automatically and cannot be called by your code. Captions can be reset by overridinggetUsernameCaption()
,getPasswordCaption()
andgetLoginButtonCaption()
.Note that the API of LoginForm changed significantly in Vaadin 7.7.
Since:
5.3
See Also:
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LoginForm.LoginEvent
Event sent when the login form is submitted.
static interface
LoginForm.LoginListener
Listener triggered when a login occurs in a
LoginForm
.-
Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
-
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
Component.ErrorEvent, Component.Event, Component.Focusable, Component.Listener
-
Nested classes/interfaces inherited from interface com.vaadin.ui.HasComponents
HasComponents.ComponentAttachDetachNotifier, HasComponents.ComponentAttachEvent, HasComponents.ComponentAttachListener, HasComponents.ComponentDetachEvent, HasComponents.ComponentDetachListener
-
Nested classes/interfaces inherited from interface com.vaadin.server.Sizeable
Sizeable.Unit
-
-
Field Summary
-
Fields inherited from class com.vaadin.ui.AbstractComponent
DESIGN_ATTR_PLAIN_TEXT
-
Fields inherited from interface com.vaadin.server.Sizeable
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
-
-
Constructor Summary
Constructors Constructor Description LoginForm()
-
Method Summary
All Methods Modifier and Type Method Description Registration
addLoginListener(LoginForm.LoginListener listener)
Adds a
LoginForm.LoginListener
.void
attach()
Notifies the connector that it is connected to a VaadinSession (and therefore also to a UI).
protected Component
createContent(TextField userNameField, PasswordField passwordField, Button loginButton)
Create the content for the login form with the supplied user name field, password field and the login button.
protected Button
createLoginButton()
Customize the login button.
protected PasswordField
createPasswordField()
Customize the password field.
protected TextField
createUsernameField()
Customize the user name field.
String
getLoginButtonCaption()
Gets the caption set with
setLoginButtonCaption(String)
.String
getPasswordCaption()
Gets the caption set with
setPasswordCaption(String)
.protected LoginFormState
getState()
Returns the shared state bean with information to be sent from the server to the client.
protected LoginFormState
getState(boolean markAsDirty)
Returns the shared state for this connector.
String
getUsernameCaption()
Gets the caption set with
setUsernameCaption(String)
.void
removeLoginListener(LoginForm.LoginListener listener)
Deprecated.
As of 8.0, replaced byRegistration.remove()
in the registration object returned fromaddLoginListener(LoginListener)
.void
setLoginButtonCaption(String loginButtonCaption)
Sets the caption of the login button.
void
setPasswordCaption(String passwordCaption)
Set the caption of the password field.
void
setUsernameCaption(String usernameCaption)
Sets the caption of the user name field.
-
Methods inherited from class com.vaadin.ui.AbstractSingleComponentContainer
addComponentAttachListener, addComponentDetachListener, fireComponentAttachEvent, fireComponentDetachEvent, getComponentCount, getContent, iterator, readDesign, readDesignChildren, removeComponentAttachListener, removeComponentDetachListener, removeFromParent, setContent, setHeight, setWidth, writeDesign
-
Methods inherited from class com.vaadin.ui.AbstractComponent
addContextClickListener, addListener, addShortcutListener, addStyleName, beforeClientResponse, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, focus, getActionManager, getCaption, getComponentError, getCustomAttributes, getData, getDebugId, getDescription, getErrorMessage, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isOrHasAncestor, isReadOnly, isRequiredIndicatorVisible, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setDescription, setEnabled, setHeight, setHeightFull, setHeightUndefined, setIcon, setId, setLocale, setParent, setPrimaryStyleName, setReadOnly, setRequiredIndicatorVisible, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth, setWidthFull, setWidthUndefined
-
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstate
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
-
Methods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, addStyleNames, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isVisible, removeListener, removeStyleName, removeStyleNames, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setStyleName, setStyleName, setVisible
-
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface com.vaadin.server.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeightFull, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidthFull, setWidthUndefined
-
-
-
-
Method Detail
-
createUsernameField
protected TextField createUsernameField()
Customize the user name field. Only for overriding, do not call.
Returns:
the user name field
Since:
7.7
-
getUsernameCaption
public String getUsernameCaption()
Gets the caption set with
setUsernameCaption(String)
. Note that this method might not match what is shown to the user ifcreateUsernameField()
has been overridden.Returns:
the user name field caption
-
setUsernameCaption
public void setUsernameCaption(String usernameCaption)
Sets the caption of the user name field. Note that the caption can only be set with this method before the login form has been initialized (attached).
As an alternative to calling this method, the method
createUsernameField()
can be overridden.Parameters:
usernameCaption
- the caption to set for the user name field
-
createPasswordField
protected PasswordField createPasswordField()
Customize the password field. Only for overriding, do not call.
Returns:
the password field
Since:
7.7
-
getPasswordCaption
public String getPasswordCaption()
Gets the caption set with
setPasswordCaption(String)
. Note that this method might not match what is shown to the user ifcreatePasswordField()
has been overridden.Returns:
the password field caption
-
setPasswordCaption
public void setPasswordCaption(String passwordCaption)
Set the caption of the password field. Note that the caption can only be set with this method before the login form has been initialized (attached).
As an alternative to calling this method, the method
createPasswordField()
can be overridden.Parameters:
passwordCaption
- the caption for the password field
-
createLoginButton
protected Button createLoginButton()
Customize the login button. Only for overriding, do not call.
Returns:
the login button
Since:
7.7
-
getLoginButtonCaption
public String getLoginButtonCaption()
Gets the caption set with
setLoginButtonCaption(String)
. Note that this method might not match what is shown to the user ifcreateLoginButton()
has been overridden.Returns:
the login button caption
-
setLoginButtonCaption
public void setLoginButtonCaption(String loginButtonCaption)
Sets the caption of the login button. Note that the caption can only be set with this method before the login form has been initialized (attached).
As an alternative to calling this method, the method
createLoginButton()
can be overridden.Parameters:
loginButtonCaption
- new caption
-
getState
protected LoginFormState getState()
Description copied from class:
AbstractComponent
Returns the shared state bean with information to be sent from the server to the client. Subclasses should override this method and set any relevant fields of the state returned by super.getState().
Overrides:
getState
in classAbstractSingleComponentContainer
Returns:
updated component shared state
-
getState
protected LoginFormState getState(boolean markAsDirty)
Description copied from class:
AbstractClientConnector
Returns the shared state for this connector.
Overrides:
getState
in classAbstractSingleComponentContainer
Parameters:
markAsDirty
- true if the connector should automatically be marked dirty, false otherwiseReturns:
The shared state for this connector. Never null.
See Also:
-
attach
public void attach()
Description copied from interface:
ClientConnector
Notifies the connector that it is connected to a VaadinSession (and therefore also to a UI).
The caller of this method is
Component.setParent(HasComponents)
if the parent is itself already attached to the session. If not, the parent will call theClientConnector.attach()
for all its children when it is attached to the session. This method is always called before the connector's data is sent to the client-side for the first time.The attachment logic is implemented in
AbstractClientConnector
.Specified by:
attach
in interfaceClientConnector
Specified by:
Overrides:
attach
in classAbstractComponent
-
createContent
protected Component createContent(TextField userNameField, PasswordField passwordField, Button loginButton)
Create the content for the login form with the supplied user name field, password field and the login button. You cannot use any other text fields or buttons for this purpose. To replace these components with your own implementations, override
createUsernameField()
,createPasswordField()
andcreateLoginButton()
. If you only want to change the default captions, overridegetUsernameCaption()
,getPasswordCaption()
andgetLoginButtonCaption()
. You do not have to use the login button in your layout.Parameters:
userNameField
- the user name text fieldpasswordField
- the password fieldloginButton
- the login buttonReturns:
content component
Since:
7.7
-
addLoginListener
public Registration addLoginListener(LoginForm.LoginListener listener)
Adds a
LoginForm.LoginListener
.The listener is called when the user presses the login button.
Parameters:
listener
- the listener to addReturns:
a registration object for removing the listener
Since:
8.0
-
removeLoginListener
@Deprecated public void removeLoginListener(LoginForm.LoginListener listener)
Deprecated.As of 8.0, replaced byRegistration.remove()
in the registration object returned fromaddLoginListener(LoginListener)
.Removes a
LoginForm.LoginListener
.Parameters:
listener
- the listener to remove
-
-