On Wednesday, June 4, 2014 5:43:58 AM UTC+2, Colin Alworth wrote:
>
> I've just opened https://gwt-review.googlesource.com/7780 to make it
> possible to specify a fallback for any/all useragents that don't match one
> of the built-in rules, via a rule like:
>
> <set-property-fallback name="user.agent" value="webkit"/>
>
> This example rule treats any unknown useragent as if it were webkit,
> rather than the non-existent 'unknown' useragent, which subsequently tries
> to load undefined.cache.html, etc. This could also be used in conjunction
> with defining a user.agent value for unknown browsers and falling back to
> an existing one (like Thomas suggested), along with a possible error
> message, but that runs the risk of failing to match any CssResource @if
> rules, for example. This will of course create a huge amount of warnings in
> your application "Could not find an exact match rule. Using 'closest'
> rule..." when attempt to rebind things that cannot be matched to unknown
> and fall back to gecko1_8, etc.
>
> <!-- Create new value, try and use ff details for it (most of the
> time) -->
> <extend-property name="user.agent" values="unknown"
> fallback-value="gecko1_8" />
> <!-- this line is not actually necessary unless you want to use a
> string other than 'unknown', and won't work before the above patch -->
> <set-property-fallback name="user.agent" value="unknown"/>
> <!-- 'most of the time' we want ff, except for a warning when the page
> boots. -->
> <!-- To achieve that, we create a second entrypoint that extends the
> real one, but also displays a warning about this browser being unsupported
> -->
> <replace-with class="pack.age.to.client.UnknownBrowserEntryPoint">
> <when-type-is class="pack.age.to.client.RealAppEntryPoint" />
> </replace-with>
>
> Thomas, were you suggesting a filter in GWT itself to let the server do
> this, or to have an 'UnknownUserAgentEntryPoint' built into GWT itself?
>
I don't remember, but I don't think so.
>From the review, I think having UserAgent#getRuntimeValue() returning
'unknown' in the fallback case would be enough:
class FallbackEntrypoint extends MainEntrypoint {
@Override
public void onModuleLoad() {
super.onModuleLoad();
UserAgent userAgent = GWT.create(UserAgent.class);
if ("unknown".equals(userAgent.getRuntimeValue())) {
// display warning
}
}
<replace-with class="com.example.client.FallbackEntrypoint">
<when-type-is class="com.example.client.MyEntrypoint" />
<when-property-is name="user.agent" value="gecko1_8" /> <!-- same value
as user.agent fallback -->
</replace-with>
<set-property-fallback name="user.agent" value="gecko1_8" />
Similar to what you proposed but without the <extend-property> that would
cause a lot of compile-time warnings.
(note: you can even make this reusable by putting it in a gwt.xml and
having MyEntrypoint be a no-op; you'd then have 2 entry-points in your app
when you inherit this module, just like Logging, DocumentMode and UserAgent
add their own entry-points)
>
--
You received this message because you are subscribed to the Google Groups "GWT
Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-web-toolkit-contributors/919cba09-62fe-40e8-9209-f5579e88bc17%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.