Oeps, I wasn't finished yet, and pressed send. Let's continue were I left
off:
BTW: the above rewrite rule with resource in it, can be removed if you
don't have that path. Ensure to put the above in the <Directory> tag, else
the REQUEST_FILENAME will not be filled yet and will contain the URI, and
that's not what you want, such that it doesn't work... (took me some time
to figger that out ;)

Then in the front-end, do what ever you want with the url it's start with,
show the context what you want.

Then the pushState thing. I started with the gwt-pushstate project on
github, but it doesn't work with gwt 2.7 due to changes in the gwt History
class.
As such, I replaced the History class with my own version that I use. It
can use the old url fragment style or the push state if supported (not
tested all well I have to admit).
Have a look at the code attached, start with the BrowserHistory class, that
is the replacement class of the gwt History class, and also contains a lot
of code of that class. It will talk to a SimpleBrowserHistory class that is
created through deferred binding and will use the pushState subclass if
pushState is supported. The support is detected though the attached gwt
file (thanks to code from gwt-pushstate on github).
I might change some thinks in the future if I have a moment and optimize
thinks, but for now it works well.
Just look around in the code, and if you have any questions, just shoot.





​

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Attachment: SimpleBrowserHistory.java
Description: Binary data

Attachment: BrowserHistory.java
Description: Binary data

Attachment: PushStateHistory.java
Description: Binary data

<?xml version="1.0" encoding="UTF-8"?>
<!-- @author Ed Bras. -->
<module>
	<inherits name="com.google.gwt.core.Core" />
	<inherits name="com.google.gwt.user.User" />
	<inherits name="com.google.gwt.user.History" />
	<inherits name="com.google.gwt.user.Window" />
	<inherits name="com.google.gwt.logging.LoggingDisabled" />

	<inherits name="com.ited.gwt.misc.Misc" />

	<!-- Where the compiler should look for the code. -->
	<source path='client' />

	<!-- Property indicating HTML5 pushState support. -->
	<define-property name="history.pushStateSupported" values="yes,no" />

	<!-- Enable/Disable HTML5 pushState based on the availability of the Javascript function. -->
	<property-provider name="history.pushStateSupported">
    <![CDATA[
      if (typeof(window.history.pushState) == "function") {
        return "yes";
      } 
      else {
        return "no";
      }
    ]]>
	</property-provider>

	<!-- Constrain the pushState property for obvious cases to avoid permutation explosion. -->
	<set-property name="history.pushStateSupported" value="no">
		<any>
			<when-property-is name="user.agent" value="ie6" />
			<when-property-is name="user.agent" value="ie8" />
		</any>
	</set-property>

	<!-- IE8 does not work with the standard implementation -->
	<replace-with class="com.ited.gwt.history.client.SimpleBrowserHistory.HistoryImplIE8">
		<when-type-is class="com.ited.gwt.history.client.SimpleBrowserHistory" />
		<all>
			<!-- prevent fallback for IE9 -->
			<none>
				<when-property-is name="user.agent" value="ie9" />
			</none>
			<when-property-is name="user.agent" value="ie8" />
		</all>
	</replace-with>

	<!-- Configure pushState history support. -->
	<replace-with class="com.ited.gwt.history.client.PushStateHistory">
		<when-type-is class="com.ited.gwt.history.client.SimpleBrowserHistory" />
		<all>
			<when-property-is name="history.pushStateSupported" value="yes" />
		</all>
	</replace-with>
	<replace-with class="com.ited.gwt.history.client.PushStateHistoryConverter">
		<when-type-is class="com.ited.gwt.history.client.HistoryConverter" />
		<all>
			<when-property-is name="history.pushStateSupported" value="yes" />
		</all>
	</replace-with>

	<!-- Configure hash history support. -->
	<replace-with class="com.ited.gwt.history.client.HashHistoryConverter">
		<when-type-is class="com.ited.gwt.history.client.HistoryConverter" />
		<all>
			<when-property-is name="history.pushStateSupported" value="no" />
		</all>
	</replace-with>

	<!-- Configure Hyperlink replacements. -->
	<replace-with class="com.ited.gwt.history.client.PushStateHyperlink">
		<when-type-is class="com.google.gwt.user.client.Hyperlink" />
	</replace-with>
	<replace-with class="com.ited.gwt.history.client.PushStateInlineHyperlink">
		<when-type-is class="com.google.gwt.user.client.InlineHyperlink" />
	</replace-with>
</module>

Reply via email to