com.vaadin.ui.


Class LoginForm

java.lang.Object
  com.vaadin.ui.AbstractComponent
      com.vaadin.ui.AbstractComponentContainer
          com.vaadin.ui.CustomComponent
              com.vaadin.ui.LoginForm

All Implemented Interfaces:

MethodEventSource, Paintable, Sizeable, VariableOwner, Component, ComponentContainer, Serializable, EventListener

public class LoginForm
extends CustomComponent

LoginForm is a Vaadin component to handle common problem among Ajax applications: browsers password managers don't fill dynamically created forms like all those UI elements created by Vaadin.

For developer it is easy to use: add component to a desired place in you UI and add LoginListener to validate form input. Behind the curtain LoginForm creates an iframe with static html that browsers detect.

Login form is by default 100% width and height, so consider using it inside a sized Panel or Window.

Login page html can be overridden by replacing protected getLoginHTML method. As the login page is actually an iframe, styles must be handled manually. By default component tries to guess the right place for theme css.

Since:

5.3

See Also:

Serialized Form

Nested Class Summary
 class LoginForm.LoginEvent
          This event is sent when login form is submitted.
static interface LoginForm.LoginListener
          Login listener is a class capable to listen LoginEvents sent from LoginBox
 
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractComponent
AbstractComponent.ComponentErrorEvent, AbstractComponent.ComponentErrorHandler
 
Nested classes/interfaces inherited from interface com.vaadin.ui.ComponentContainer
ComponentContainer.ComponentAttachEvent, ComponentContainer.ComponentAttachListener, ComponentContainer.ComponentDetachEvent, ComponentContainer.ComponentDetachListener
 
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
Component.ErrorEvent, Component.ErrorListener, Component.Event, Component.Focusable, Component.Listener
 
Nested classes/interfaces inherited from interface com.vaadin.terminal.Paintable
Paintable.RepaintRequestEvent, Paintable.RepaintRequestListener
 
Field Summary
 
Fields inherited from interface com.vaadin.terminal.Sizeable
SIZE_UNDEFINED, UNIT_SYMBOLS, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
 
Constructor Summary
LoginForm()
           
 
Method Summary
 void addListener(LoginForm.LoginListener listener)
          Adds LoginListener to handle login logic
 void attach()
          Notifies all contained components that the container is attached to a window.
 void detach()
          Notifies all contained components that the container is detached from a window.
 String getLoginButtonCaption()
          Returns the caption for the login button.
protected  byte[] getLoginHTML()
          Returns byte array containing login page html.
 String getPasswordCaption()
          Returns the caption for the password field.
 String getUsernameCaption()
          Returns the caption for the user name field.
 void removeListener(LoginForm.LoginListener listener)
          Removes LoginListener
 void setHeight(float height, int unit)
          Sets the height of the object.
 void setLoginButtonCaption(String loginButtonCaption)
          Sets the caption (button text) to show for the login button.
 void setPasswordCaption(String passwordCaption)
          Sets the caption to show for the password field.
 void setUsernameCaption(String usernameCaption)
          Sets the caption to show for the user name field.
 void setWidth(float width, int unit)
          Sets the width of the object.
 
Methods inherited from class com.vaadin.ui.CustomComponent
addComponent, getComponentCount, getComponentIterator, getComponentType, getCompositionRoot, moveComponentsFrom, paintContent, removeAllComponents, removeComponent, replaceComponent, setComponentType, setCompositionRoot
 
Methods inherited from class com.vaadin.ui.AbstractComponentContainer
addListener, addListener, fireComponentAttachEvent, fireComponentDetachEvent, removeListener, removeListener, requestRepaintAll, setEnabled
 
Methods inherited from class com.vaadin.ui.AbstractComponent
addListener, addListener, addListener, addListener, addListener, addStyleName, changeVariables, childRequestedRepaint, fireComponentErrorEvent, fireComponentEvent, fireEvent, focus, getApplication, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorHandler, getErrorMessage, getHeight, getHeightUnits, getIcon, getListeners, getLocale, getParent, getStyle, getStyleName, getWidth, getWidthUnits, getWindow, handleError, hasListeners, isEnabled, isImmediate, isReadOnly, isVisible, paint, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeStyleName, requestRepaint, requestRepaintRequests, setCaption, setComponentError, setData, setDebugId, setDescription, setErrorHandler, setHeight, setHeight, setHeightUnits, setIcon, setImmediate, setLocale, setParent, setReadOnly, setSizeFull, setSizeUndefined, setStyle, setStyleName, setVisible, setWidth, setWidth, setWidthUnits
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, childRequestedRepaint, getApplication, getCaption, getIcon, getLocale, getParent, getStyleName, getWindow, isEnabled, isReadOnly, isVisible, removeListener, removeStyleName, setCaption, setIcon, setParent, setReadOnly, setStyleName, setVisible
 
Methods inherited from interface com.vaadin.terminal.Paintable
addListener, getDebugId, paint, removeListener, requestRepaint, requestRepaintRequests, setDebugId
 
Methods inherited from interface com.vaadin.terminal.VariableOwner
changeVariables, isImmediate
 
Methods inherited from interface com.vaadin.terminal.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightUnits, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthUnits
 

Constructor Detail

LoginForm

public LoginForm()
Method Detail

getLoginHTML

protected byte[] getLoginHTML()

Returns byte array containing login page html. If you need to override the login html, use the default html as basis. Login page sets its target with javascript.

Returns:
byte array containing login page html

attach

public void attach()

Description copied from class: AbstractComponentContainer

Notifies all contained components that the container is attached to a window.

Specified by:
attach in interface Component
Overrides:
attach in class AbstractComponentContainer

See Also:
Component.attach()

detach

public void detach()

Description copied from class: AbstractComponentContainer

Notifies all contained components that the container is detached from a window.

Specified by:
detach in interface Component
Overrides:
detach in class AbstractComponentContainer

See Also:
Component.detach()

addListener

public void addListener(LoginForm.LoginListener listener)

Adds LoginListener to handle login logic

Parameters:
listener -

removeListener

public void removeListener(LoginForm.LoginListener listener)

Removes LoginListener

Parameters:
listener -

setWidth

public void setWidth(float width,
                     int unit)

Description copied from interface: Sizeable

Sets the width of the object. Negative number implies unspecified size (terminal is free to set the size).

Specified by:
setWidth in interface Sizeable
Overrides:
setWidth in class AbstractComponentContainer

Parameters:
width - the width of the object.
unit - the unit used for the width. Possible values include Sizeable.UNITS_PIXELS, Sizeable.UNITS_POINTS, Sizeable.UNITS_PICAS, Sizeable.UNITS_EM, Sizeable.UNITS_EX, Sizeable.UNITS_MM, Sizeable.UNITS_CM, Sizeable.UNITS_INCH, Sizeable.UNITS_PERCENTAGE.

setHeight

public void setHeight(float height,
                      int unit)

Description copied from interface: Sizeable

Sets the height of the object. Negative number implies unspecified size (terminal is free to set the size).

Specified by:
setHeight in interface Sizeable
Overrides:
setHeight in class AbstractComponentContainer

Parameters:
height - the height of the object.
unit - the unit used for the width. Possible values include Sizeable.UNITS_PIXELS, Sizeable.UNITS_POINTS, Sizeable.UNITS_PICAS, Sizeable.UNITS_EM, Sizeable.UNITS_EX, Sizeable.UNITS_MM, Sizeable.UNITS_CM, Sizeable.UNITS_INCH, Sizeable.UNITS_PERCENTAGE.

getUsernameCaption

public String getUsernameCaption()

Returns the caption for the user name field.

Returns:
String

setUsernameCaption

public void setUsernameCaption(String 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.

Parameters:
usernameCaption -

getPasswordCaption

public String getPasswordCaption()

Returns the caption for the password field.

Returns:
String

setPasswordCaption

public void setPasswordCaption(String passwordCaption)

Sets the caption to show for the password field. The caption cannot be changed after the form has been shown to the user.

Parameters:
passwordCaption -

getLoginButtonCaption

public String getLoginButtonCaption()

Returns the caption for the login button.

Returns:
String

setLoginButtonCaption

public void setLoginButtonCaption(String 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.

Parameters:
loginButtonCaption -