com.vaadin.server.
Class BrowserWindowOpener
- java.lang.Object
-
- com.vaadin.server.AbstractClientConnector
-
- com.vaadin.server.AbstractExtension
-
- com.vaadin.server.BrowserWindowOpener
-
All Implemented Interfaces:
MethodEventSource
,ClientConnector
,Extension
,Connector
,Serializable
public class BrowserWindowOpener extends AbstractExtension
Component extension that opens a browser popup window when the extended component is clicked.
Since:
7.0.0
Author:
Vaadin Ltd
See Also:
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
-
-
Constructor Summary
Constructors Constructor Description BrowserWindowOpener(Resource resource)
Creates a window opener that will open window to the provided resource.
BrowserWindowOpener(Class<? extends UI> uiClass)
Creates a window opener that will open windows containing the provided UI class.
BrowserWindowOpener(Class<? extends UI> uiClass, String path)
Creates a window opener that will open windows containing the provided UI using the provided path.
BrowserWindowOpener(String url)
Creates a window opener that will open windows to the provided URL.
-
Method Summary
All Methods Modifier and Type Method Description void
attach()
Notifies the connector that it is connected to a VaadinSession (and therefore also to a UI).
void
detach()
Notifies the connector that it is detached from its VaadinSession.
void
extend(EventTrigger eventTrigger)
Add this extension to the
EventTrigger
.void
extend(AbstractComponent target)
Add this extension to the target component.
String
getFeatures()
Gets the window features.
String
getParameter(String name)
Gets the value of a parameter set using
setParameter(String, String)
.Set<String>
getParameterNames()
Gets the names of all parameters set using
setParameter(String, String)
.Resource
getResource()
Returns the resource for this instance.
protected BrowserWindowOpenerState
getState()
Returns the shared state for this connector.
protected BrowserWindowOpenerState
getState(boolean markAsDirty)
Returns the shared state for this connector.
String
getUriFragment()
Gets that URI fragment configured for opened windows.
String
getUrl()
Returns the URL for this BrowserWindowOpener instance.
String
getWindowName()
Gets the target window name.
void
removeParameter(String name)
Removes a parameter that has been set using
setParameter(String, String)
.void
setFeatures(String features)
Sets the features for opening the window.
void
setParameter(String name, String value)
Sets a parameter that will be added to the query string of the opened URI.
void
setResource(Resource resource)
Sets the provided
resource
for this instance.void
setUriFragment(String uriFragment)
Sets a URI fragment that will be added to the URI opened in the window.
void
setUrl(String url)
Sets the provided URL
url
for this instance.void
setWindowName(String windowName)
Sets the target window name that will be used.
-
Methods inherited from class com.vaadin.server.AbstractExtension
extend, getParent, getSupportedParentType, remove, setParent
-
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addListener, addListener, addListener, addMethodInvocationToQueue, beforeClientResponse, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isConnectorEnabled, 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, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, getUI, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
-
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
-
-
-
-
Constructor Detail
-
BrowserWindowOpener
public BrowserWindowOpener(Class<? extends UI> uiClass)
Creates a window opener that will open windows containing the provided UI class.
Note: The new UI instance will not work with dependency injection (CDI and Spring). Use
BrowserWindowOpener(java.lang.String)
instead.VaadinServlet.getCurrent().getServletContext().getContextPath()
gives the current context path.Parameters:
uiClass
- the UI class that should be opened when the extended component is clicked
-
BrowserWindowOpener
public BrowserWindowOpener(Class<? extends UI> uiClass, String path)
Creates a window opener that will open windows containing the provided UI using the provided path.
Note: The new UI instance will not work with dependency injection (CDI and Spring). Use
BrowserWindowOpener(java.lang.String)
instead.VaadinServlet.getCurrent().getServletContext().getContextPath()
gives the current context path.Parameters:
uiClass
- the UI class that should be opened when the extended component is clickedpath
- the path that the UI should be bound to
-
BrowserWindowOpener
public BrowserWindowOpener(String url)
Creates a window opener that will open windows to the provided URL.
Parameters:
url
- the URL to open in the window
-
BrowserWindowOpener
public BrowserWindowOpener(Resource resource)
Creates a window opener that will open window to the provided resource.
Parameters:
resource
- the resource to open in the window
-
-
Method Detail
-
extend
public void extend(AbstractComponent target)
Add this extension to the target component.
Parameters:
target
- the component to attach this extension to
-
extend
public void extend(EventTrigger eventTrigger)
Add this extension to the
EventTrigger
.Parameters:
eventTrigger
- the trigger to attach this extension toSince:
8.4
-
setUrl
public void setUrl(String url)
Sets the provided URL
url
for this instance. Theurl
will be opened in a new browser window/tab when the extended component is clicked.Parameters:
url
- URL to openSince:
7.4
-
setResource
public void setResource(Resource resource)
Sets the provided
resource
for this instance. Theresource
will be opened in a new browser window/tab when the extended component is clicked.Parameters:
resource
- resource to openSince:
7.4
-
getResource
public Resource getResource()
Returns the resource for this instance.
Returns:
resource to open browser window
Since:
7.4
-
getUrl
public String getUrl()
Returns the URL for this BrowserWindowOpener instance. Returns
null
if this instance is not URL resource based (a non URL based resource has been set for it).Returns:
URL to open in the new browser window/tab when the extended component is clicked
Since:
7.4
-
setWindowName
public void setWindowName(String windowName)
Sets the target window name that will be used. If a window has already been opened with the same name, the contents of that window will be replaced instead of opening a new window. If the name is
null
or"_blank"
, a new window will always be opened.Parameters:
windowName
- the target name for the window
-
getWindowName
public String getWindowName()
Gets the target window name.
Returns:
the window target string
See Also:
-
setFeatures
public void setFeatures(String features)
Sets the features for opening the window. See e.g. https://developer.mozilla.org/en-US/docs/DOM/window.open#Position_and_size_features for a description of the commonly supported features.
Parameters:
features
- a string with window features, ornull
to use the default features.
-
getFeatures
public String getFeatures()
Gets the window features.
Returns:
See Also:
-
getState
protected BrowserWindowOpenerState getState()
Description copied from class:
AbstractClientConnector
Returns the shared state for this connector. The shared state object is shared between the server connector and the client connector. Changes are only communicated from the server to the client and not in the other direction.
As a side effect, marks the connector dirty so any changes done to the state will be sent to the client. Use
getState(false)
to avoid marking the connector as dirty.Overrides:
getState
in classAbstractClientConnector
Returns:
The shared state for this connector. Never null.
-
getState
protected BrowserWindowOpenerState getState(boolean markAsDirty)
Description copied from class:
AbstractClientConnector
Returns the shared state for this connector.
Overrides:
getState
in classAbstractClientConnector
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
Overrides:
attach
in classAbstractClientConnector
-
detach
public void detach()
Description copied from class:
AbstractClientConnector
Notifies the connector that it is detached from its VaadinSession.
The caller of this method is
Component.setParent(HasComponents)
if the parent is in the session. When the parent is detached from the session it is its responsibility to callClientConnector.detach()
for each of its children.The
AbstractClientConnector.getSession()
andAbstractClientConnector.getUI()
methods might returnnull
after this method is called.Specified by:
detach
in interfaceClientConnector
Overrides:
detach
in classAbstractClientConnector
-
setUriFragment
public void setUriFragment(String uriFragment)
Sets a URI fragment that will be added to the URI opened in the window. If the window is opened to contain a Vaadin UI, the fragment will be available using
Page.getUriFragment()
on the Page instance of the new UI.The default value is
null
.Parameters:
uriFragment
- the URI fragment string that should be included in the opened URI, ornull
to preserve the original fragment of the URI.
-
getUriFragment
public String getUriFragment()
Gets that URI fragment configured for opened windows.
Returns:
the URI fragment string, or
null
if no fragment is configured.See Also:
-
setParameter
public void setParameter(String name, String value)
Sets a parameter that will be added to the query string of the opened URI. If the window is opened to contain a Vaadin UI, the parameter will be available using
VaadinRequest.getParameter(String)
e.g. using the request instance passed toUI.init(VaadinRequest)
.Setting a parameter with the same name as a previously set parameter will replace the previous value.
Parameters:
name
- the name of the parameter to add, notnull
value
- the value of the parameter to add, notnull
See Also:
removeParameter(String)
,getParameterNames()
,getParameter(String)
-
removeParameter
public void removeParameter(String name)
Removes a parameter that has been set using
setParameter(String, String)
. Removing a parameter that has not been set has no effect.Parameters:
name
- the name of the parameter to remove, notnull
See Also:
-
getParameterNames
public Set<String> getParameterNames()
Gets the names of all parameters set using
setParameter(String, String)
.Returns:
an unmodifiable set of parameter names
See Also:
-
getParameter
public String getParameter(String name)
Gets the value of a parameter set using
setParameter(String, String)
. If there is no parameter with the given name,null
is returned.Parameters:
name
- the name of the parameter to get, notnull
Returns:
the value of the parameter, or
null
there is no parameterSee Also:
-
-