Package com.vaadin.flow.component.login
Class AbstractLogin
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.login.AbstractLogin
- All Implemented Interfaces:
AttachNotifier
,DetachNotifier
,HasElement
,HasEnabled
,HasStyle
,Serializable
- Direct Known Subclasses:
LoginForm
,LoginOverlay
Abstract component for the
<vaadin-login-overlay>
and
<vaadin-login-form>
components. On AbstractLogin.LoginEvent
component becomes disabled. Disabled component stops to process login events,
however the AbstractLogin.ForgotPasswordEvent
event is processed anyway.
To enable use the
HasEnabled.setEnabled(boolean)
method.
Setting error setError(boolean)
true makes component automatically
enabled for the next login attempt.
Server side login listener do not work in combination with HTML form submission configured by setting the
action
attribute. The reason is
that form submission, depending on the authentication process result, will
cause a redirection to a different page or to current login view. In both
cases a new Flow UI will be created and the event will potentially be
forwarded to a dismissed UI. In addition, if the HTTP session ID is changed
as a consequence of the authentication process, the server may respond to the
login event with a session expiration error, cause a client resynchronization
that can in turn cancel a potential redirect issued by the form submission.- Author:
- Vaadin Ltd
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
`forgot-password` is fired when the user clicks Forgot password buttonstatic class
`login` is fired when the user either clicks Submit button or presses an Enter key. -
Constructor Summary
ConstructorsConstructorDescriptionInitializes a new AbstractLogin with a default localization.AbstractLogin
(LoginI18n i18n) Initializes a new AbstractLogin. -
Method Summary
Modifier and TypeMethodDescriptionAdds `forgotPassword` event listener.Adds `login` event listener.Returns the action defined for a login form.boolean
isError()
Returns whether the error message is displayed or notboolean
Returns whether the forgot password button is visible or notvoid
onEnabledStateChanged
(boolean enabled) Handle component enable state when the enabled state changes.void
Sets the path where to send the form-data when a form is submitted.void
setError
(boolean error) Sets whether to show or hide the error message.void
setForgotPasswordButtonVisible
(boolean forgotPasswordButtonVisible) Sets whether to show or hide the forgot password button.void
Sets the internationalized messages to be used by this instance.void
showErrorMessage
(String title, String message) Shows given error message and setssetError(boolean)
to true.Methods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisible
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListener
Methods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
Methods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabled
Methods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Constructor Details
-
AbstractLogin
public AbstractLogin()Initializes a new AbstractLogin with a default localization. -
AbstractLogin
Initializes a new AbstractLogin.- Parameters:
i18n
- internationalized messages to be used by this instance.
-
-
Method Details
-
setAction
Sets the path where to send the form-data when a form is submitted. Once action is defined aAbstractLogin.LoginEvent
is not fired anymore.The
action
attribute should not be used together with login listeners added withaddLoginListener(ComponentEventListener)
. See class Javadoc for more information. -
getAction
Returns the action defined for a login form.- Returns:
- the value of action property
-
setError
public void setError(boolean error) Sets whether to show or hide the error message. The message can be set viasetI18n(LoginI18n)
Calling this method withtrue
will also enable the component.- Parameters:
error
-true
to show the error message and enable component for next login attempt,false
to hide an error- See Also:
-
isError
Returns whether the error message is displayed or not- Returns:
- the value of error property
-
setForgotPasswordButtonVisible
public void setForgotPasswordButtonVisible(boolean forgotPasswordButtonVisible) Sets whether to show or hide the forgot password button. The button is visible by default- Parameters:
forgotPasswordButtonVisible
- whether to display or hide the button- See Also:
-
isForgotPasswordButtonVisible
public boolean isForgotPasswordButtonVisible()Returns whether the forgot password button is visible or not- Returns:
true
if the forgot password button is visiblefalse
otherwise
-
setI18n
Sets the internationalized messages to be used by this instance.- Parameters:
i18n
- the internationalized messages- See Also:
-
showErrorMessage
Shows given error message and setssetError(boolean)
to true.- Parameters:
title
- theerror message title
, may be null.message
- theerror message
, may be null.
-
addLoginListener
Adds `login` event listener.Login listeners should not be used together with the
action
attribute. See class Javadoc for more information.- See Also:
-
addForgotPasswordListener
public Registration addForgotPasswordListener(ComponentEventListener<AbstractLogin.ForgotPasswordEvent> listener) Adds `forgotPassword` event listener. Event continues being process even if the component is notHasEnabled.isEnabled()
. -
onEnabledStateChanged
public void onEnabledStateChanged(boolean enabled) Description copied from class:Component
Handle component enable state when the enabled state changes.By default this sets or removes the 'disabled' attribute from the element. This can be overridden to have custom handling.
- Overrides:
onEnabledStateChanged
in classComponent
- Parameters:
enabled
- the new enabled state of the component
-