All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.vaadin.polymer.app.widget.AppLocation Maven / Gradle / Ivy

There is a newer version: 1.9.3.1
Show newest version
/*
 * This code was generated with Vaadin Web Component GWT API Generator, 
 * from app-route project by The Polymer Authors
 * that is licensed with http://polymer.github.io/LICENSE.txt license.
 */
package com.vaadin.polymer.app.widget;

import com.vaadin.polymer.app.*;

import com.vaadin.polymer.*;
import com.vaadin.polymer.elemental.*;
import com.vaadin.polymer.PolymerWidget;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.core.client.JavaScriptObject;

/**
 * 

app-location is an element that provides synchronization between the
browser location bar and the state of an app. When created, app-location
elements will automatically watch the global location for changes. As changes
occur, app-location produces and updates an object called route. This
route object is suitable for passing into a app-route, and other similar
elements.

*

An example of the public API of a route object that describes the URL
https://elements.polymer-project.org/elements/app-location:

*
{
 *   prefix: '',
 *   path: '/elements/app-location'
 * }
 * 
 * 
 * 

Example Usage:

*
<app-location route="{{route}}"></app-location>
 * <app-route route="{{route}}" pattern="/:page" data="{{data}}"></app-route>
 * 
 * 
 * 

As you can see above, the app-location element produces a route and that
property is then bound into the app-route element. The bindings are two-
directional, so when changes to the route object occur within app-route,
they automatically reflect back to the global location.

*

Hashes vs Paths

*

By default app-location routes using the pathname portion of the URL. This has
broad browser support but it does require cooperation of the backend server. An
app-location can be configured to use the hash part of a URL instead using
the use-hash-as-path attribute, like so:

*
<app-location route="{{route}}" use-hash-as-path></app-location>
 * 
 * 
 * 

Integrating with other routing code

*

There is no standard event that is fired when window.location is modified.
app-location fires a location-changed event on window when it updates the
location. It also listens for that same event, and re-reads the URL when it’s
fired. This makes it very easy to interop with other routing code.

*

So for example if you want to navigate to /new_path imperatively you could
call window.location.pushState or window.location.replaceState followed by
firing a location-changed event on window. i.e.

*
window.history.pushState({}, null, '/new_path');
 * window.dispatchEvent(new CustomEvent('location-changed'));
 * 
 * 
 * 
*/ public class AppLocation extends PolymerWidget { /** * Default Constructor. */ public AppLocation() { this(""); } /** * Constructor used by UIBinder to create widgets with content. */ public AppLocation(String html) { super(AppLocationElement.TAG, AppLocationElement.SRC, html); } /** * Gets a handle to the Polymer object's underlying DOM element. */ public AppLocationElement getPolymerElement() { return (AppLocationElement) getElement(); } /** *

A set of key/value pairs that are universally accessible to branches of
the route tree.

* * JavaScript Info: * @property queryParams * @type ?Object * */ public JavaScriptObject getQueryParams() { return getPolymerElement().getQueryParams(); } /** *

A set of key/value pairs that are universally accessible to branches of
the route tree.

* * JavaScript Info: * @property queryParams * @type ?Object * */ public void setQueryParams(JavaScriptObject value) { getPolymerElement().setQueryParams(value); } /** *

A model representing the deserialized path through the route tree, as
well as the current queryParams.

* * JavaScript Info: * @property route * @type Object * */ public JavaScriptObject getRoute() { return getPolymerElement().getRoute(); } /** *

A model representing the deserialized path through the route tree, as
well as the current queryParams.

* * JavaScript Info: * @property route * @type Object * */ public void setRoute(JavaScriptObject value) { getPolymerElement().setRoute(value); } /** *

A regexp that defines the set of URLs that should be considered part
of this web app.

*

Clicking on a link that matches this regex won’t result in a full page
navigation, but will instead just update the URL state in place.

*

This regexp is given everything after the origin in an absolute
URL. So to match just URLs that start with /search/ do:
url-space-regex=”^/search/“

* * JavaScript Info: * @property urlSpaceRegex * @type (string|RegExp) * */ public Object getUrlSpaceRegex() { return getPolymerElement().getUrlSpaceRegex(); } /** *

A regexp that defines the set of URLs that should be considered part
of this web app.

*

Clicking on a link that matches this regex won’t result in a full page
navigation, but will instead just update the URL state in place.

*

This regexp is given everything after the origin in an absolute
URL. So to match just URLs that start with /search/ do:
url-space-regex=”^/search/“

* * JavaScript Info: * @property urlSpaceRegex * @type (string|RegExp) * */ public void setUrlSpaceRegex(Object value) { getPolymerElement().setUrlSpaceRegex(value); } /** *

In many scenarios, it is convenient to treat the hash as a stand-in
alternative to the path. For example, if deploying an app to a static
web server (e.g., Github Pages) - where one does not have control over
server-side routing - it is usually a better experience to use the hash
to represent paths through one’s app.

*

When this property is set to true, the hash will be used in place of

*

the path for generating a route.

* * JavaScript Info: * @property useHashAsPath * @type Boolean * */ public boolean getUseHashAsPath() { return getPolymerElement().getUseHashAsPath(); } /** *

In many scenarios, it is convenient to treat the hash as a stand-in
alternative to the path. For example, if deploying an app to a static
web server (e.g., Github Pages) - where one does not have control over
server-side routing - it is usually a better experience to use the hash
to represent paths through one’s app.

*

When this property is set to true, the hash will be used in place of

*

the path for generating a route.

* * JavaScript Info: * @property useHashAsPath * @type Boolean * */ public void setUseHashAsPath(boolean value) { getPolymerElement().setUseHashAsPath(value); } /** *

The route path, which will be either the hash or the path, depending
on useHashAsPath.

* * JavaScript Info: * @property path * @type String * */ public String getPath() { return getPolymerElement().getPath(); } /** *

The route path, which will be either the hash or the path, depending
on useHashAsPath.

* * JavaScript Info: * @property path * @type String * */ public void setPath(String value) { getPolymerElement().setPath(value); } // Needed in UIBinder /** *

A set of key/value pairs that are universally accessible to branches of
the route tree.

* * JavaScript Info: * @attribute query-params * */ public void setQueryParams(String value) { Polymer.property(this.getPolymerElement(), "queryParams", value); } // Needed in UIBinder /** *

A model representing the deserialized path through the route tree, as
well as the current queryParams.

* * JavaScript Info: * @attribute route * */ public void setRoute(String value) { Polymer.property(this.getPolymerElement(), "route", value); } // Needed in UIBinder /** *

A regexp that defines the set of URLs that should be considered part
of this web app.

*

Clicking on a link that matches this regex won’t result in a full page
navigation, but will instead just update the URL state in place.

*

This regexp is given everything after the origin in an absolute
URL. So to match just URLs that start with /search/ do:
url-space-regex=”^/search/“

* * JavaScript Info: * @attribute url-space-regex * */ public void setUrlSpaceRegex(String value) { Polymer.property(this.getPolymerElement(), "urlSpaceRegex", value); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy