gwt-pushstate implements easy to use HTML5 pushState support for GWT projects.
Copyright 2012 Johannes Barop
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Add the gwt-pushstate dependency to your project:
<dependency>
<groupId>de.barop.gwt</groupId>
<artifactId>gwt-pushstate</artifactId>
<version>1.0.0</version>
</dependency>
And inherit the PushState module in your GWT module:
<inherits name="de.barop.gwt.PushState" />
gwt-pushstate hooks onto GWT's standard History API. Because of that it plays nice with existing applications and the place mechanism of GWTP-MVP or GWT-Places still works.
The development mode still works and is not left accidently when pushing or popping history states.
Overriden Hyperlink
and InlineHyperlink
widgets for nice URLs without hashbangs.
Transparent fallback to URLs with hashes for browsers without pushState support.
- Always the complete path of an URL is treated as history token.
- Path depended stuff might break (
GWT.getHostPageBaseURL()
or GWTP-dispatch's auto discovery of service URLs). - In order to get deeplinking to work some sort of server configuration is needed (URL rewriting, see the sample).
Check it out at gwt-pushstate-examples.appspot.com.
The sample application is based on GWTP-0.7's gwtp-sample-hplace. Only a few changes where needed to get it work nicely. These are documented as commit here.
The sources are located in src/examples
however the sample is deactivated by default. You can activate it by specifying the examples
maven profile.
You can run the sample with the development mode by executing mvn gwt:run -Pexamples
or the staticly compiled version with mvn jetty:run-exploded -Pexamples
.
To get deeplinking to work all incoming URLs expect the service paths are rewritten to the GWT application here. This is done using the UrlRewriteFilter for Java which works nice for local testing and development.
If you want to import the sample application into your IDE make sure you activate the profile.
As the example uses GWT Platforms GenEvents you may have to run mvn clean compile -Pexamples
to get the generated sources generated.