public class BrowserWindowOpener extends AbstractExtension
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
Constructor and Description |
---|
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(Resource resource)
Creates a window opener that will open window to the provided resource
|
BrowserWindowOpener(String url)
Creates a window opener that will open windows to the provided URL
|
Modifier and Type | Method and 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(AbstractComponent target) |
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.
|
extend, getParent, getSupportedParentType, remove, setParent
addAttachListener, addDetachListener, addExtension, 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, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
addAttachListener, addDetachListener, beforeClientResponse, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, getUI, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
getConnectorId
public BrowserWindowOpener(Class<? extends UI> uiClass)
uiClass
- the UI class that should be opened when the extended component
is clickedpublic BrowserWindowOpener(Class<? extends UI> uiClass, String path)
uiClass
- the UI class that should be opened when the extended component
is clickedpath
- the path that the UI should be bound topublic BrowserWindowOpener(String url)
url
- the URL to open in the windowpublic BrowserWindowOpener(Resource resource)
resource
- the resource to open in the windowpublic void extend(AbstractComponent target)
public void setUrl(String url)
url
for this instance. The url
will
be opened in a new browser window/tab when the extended component is
clicked.url
- URL to openpublic void setResource(Resource resource)
resource
for this instance. The
resource
will be opened in a new browser window/tab when the
extended component is clicked.resource
- resource to openpublic Resource getResource()
public String getUrl()
null
if this instance is not URL resource based (a non URL based
resource has been set for it).public void setWindowName(String windowName)
null
or "_blank"
, a new window will always be
opened.windowName
- the target name for the windowpublic String getWindowName()
setWindowName(String)
public void setFeatures(String features)
https://developer.mozilla.org/en-US/docs/DOM/window.open#Position_and_size_features
for a description of the commonly supported features.features
- a string with window features, or null
to use the default features.public String getFeatures()
setFeatures(String)
protected BrowserWindowOpenerState getState()
AbstractClientConnector
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.
getState
in class AbstractClientConnector
protected BrowserWindowOpenerState getState(boolean markAsDirty)
AbstractClientConnector
getState
in class AbstractClientConnector
markAsDirty
- true if the connector should automatically be marked dirty,
false otherwiseAbstractClientConnector.getState()
public void attach()
ClientConnector
The caller of this method is #setParent(ClientConnector)
if the
parent is itself already attached to the session. If not, the parent will
call the ClientConnector.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
.
attach
in interface ClientConnector
attach
in class AbstractClientConnector
public void detach()
AbstractClientConnector
The caller of this method is #setParent(ClientConnector)
if the
parent is in the session. When the parent is detached from the session it
is its responsibility to call ClientConnector.detach()
for each of its children.
The AbstractClientConnector.getSession()
and AbstractClientConnector.getUI()
methods might return
null
after this method is called.
detach
in interface ClientConnector
detach
in class AbstractClientConnector
public void setUriFragment(String uriFragment)
Page.getUriFragment()
on the Page instance of the
new UI.
The default value is null
.
uriFragment
- the URI fragment string that should be included in the opened
URI, or null
to preserve the original fragment of
the URI.public String getUriFragment()
null
if no fragment is
configured.setUriFragment(String)
public void setParameter(String name, String value)
VaadinRequest.getParameter(String)
e.g. using
the request instance passed to UI.init(VaadinRequest)
.
Setting a parameter with the same name as a previously set parameter will replace the previous value.
name
- the name of the parameter to add, not null
value
- the value of the parameter to add, not null
removeParameter(String)
,
getParameterNames()
,
getParameter(String)
public void removeParameter(String name)
setParameter(String, String)
. Removing a parameter that has not
been set has no effect.name
- the name of the parameter to remove, not null
setParameter(String, String)
public Set<String> getParameterNames()
setParameter(String, String)
.setParameter(String, String)
,
getParameter(String)
public String getParameter(String name)
setParameter(String, String)
. If there is no parameter with the
given name, null
is returned.name
- the name of the parameter to get, not null
null
there is no
parametersetParameter(String, String)
,
getParameter(String)
Copyright © 2019 Vaadin Ltd. All rights reserved.