King_V
unread,Nov 21, 2012, 5:28:54 PM11/21/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to google-we...@googlegroups.com
All,
I've seen a few examples where there is talk of substituting a class based on which browser is involved.
So, I want to have one version of a class for Firefox, and one for everything else.
I've tried the following, taken from examples I've found online:
<?xml version="1.0" encoding="UTF-8"?>
<module>
<inherits name="com.sencha.gxt.theme.base.Base" />
<replace-with class="com.joev.tests.client.MultiplierAdjustmentFirefox">
<when-type-is class="com.joev.tests.client.MultiplierAdjustment" />
<when-property-is name="user.agent" value="firefox" />
</replace-with>
</module>
However, it doesn't seem to work. I'm pretty sure the value isn't just "firefox" but I don't know what to put in there. Or it may be the static method doing the instantiation of the MultiplierAdjustment class.
Basically I want any version of Firefox to use the MultiplierAdjustmentFirefox class, and other browsers (so far we're only supporting Chrome and IE) to use the MultiplierAdjustment class.
Here's the basic code I used to test it:
GenericOutput.java (yeah, I'm not very creative with my names):
public class GenericOutput implements EntryPoint {
@Override
public void onModuleLoad() {
RootPanel.get().add(new Label(GenericStuff.getClassNameForInstance() + " has a value of: " + GenericStuff.getMultiplierValue()));
}
}
GenericStuff.java:
public class GenericStuff {
private static MultiplierAdjustment instance;
private static MultiplierAdjustment getInstance() {
if(instance == null) {
instance = new MultiplierAdjustment();
}
return instance;
}
public static String getClassNameForInstance() {
return getInstance().getClass().getName();
}
public static double getMultiplierValue() {
return getInstance().getMultiplier();
}
}
MultiplierAdjustment.java:
public class MultiplierAdjustment {
public double getMultiplier() {
return 1.3;
}
}
MultiplierAdjustmentFirefox.java:
public class MultiplierAdjustmentFirefox {
public double getMultiplier() {
return 1.07;
}
}
So, why am I getting output saying: com.joev.tests.client.MultiplierAdjustment has a value of: 1.3
How do I get this to work correctly?
Thanks in advance