Problem reading property file in GWT

666 views
Skip to first unread message

Vibhuti Agarwal

unread,
Oct 11, 2010, 4:22:48 AM10/11/10
to google-a...@googlegroups.com
Hello 

I am facing problem reading property file in GWT. I created an interface which extends the Constants interface and defined methods corresponding to the properties in properties file. 
When I run my application I get the following errors:


com.google.gwt.i18n.rebind.AbstractResource$MissingResourceException: No resource found for key 'display.alert'
    at com.google.gwt.i18n.rebind.AbstractResource$ResourceList.getRequiredStringExt(AbstractResource.java:246)
    at com.google.gwt.i18n.rebind.SimpleValueMethodCreator.createMethodFor(SimpleValueMethodCreator.java:95)
    at com.google.gwt.i18n.rebind.AbstractLocalizableImplCreator.delegateToCreator(AbstractLocalizableImplCreator.java:313)
    at com.google.gwt.i18n.rebind.ConstantsImplCreator.emitMethodBody(ConstantsImplCreator.java:163)
    at com.google.gwt.user.rebind.AbstractGeneratorClassCreator.genMethod(AbstractGeneratorClassCreator.java:265)
    at com.google.gwt.user.rebind.AbstractGeneratorClassCreator.emitMethods(AbstractGeneratorClassCreator.java:233)
    at com.google.gwt.user.rebind.AbstractGeneratorClassCreator.emitClass(AbstractGeneratorClassCreator.java:116)
    at com.google.gwt.i18n.rebind.AbstractLocalizableImplCreator.generateConstantOrMessageClass(AbstractLocalizableImplCreator.java:133)

As per the java docs, I have created the properties file in the same name as the interface i.e. Test.java(I) and Test.properties. 
I am accessing the constants the following way:

public interface Test extends com.google.gwt.i18n.client.Constants{
@Key("display.alert")
    String displayAlert();
}

public static Test constants = (Test) GWT.create(Test.class);

constants.displayAlert();

Any ideas on what am I missing here.

Thanks

l.denardo

unread,
Oct 11, 2010, 9:11:47 AM10/11/10
to Google App Engine
You may have better luck in GWT discussion groups...
Anyway it seems you're mixing Constants and Message annotations.

The correct way is

class Test extends Constants{
@DefaultStringValue("this is my alert!!")
public String displayAlert();
}

//use
public static Test constants = GWT.create(Test.class); //No cast
needed
Window.alert(constants.displayAlert());

Test_**.properties
displayAlert = message for language **

Regards
Lorenzo

l.denardo

unread,
Oct 11, 2010, 9:58:27 AM10/11/10
to Google App Engine
A link to documentation on the matter:

http://code.google.com/webtoolkit/doc/latest/tutorial/i18n.html#international

Regards
Lorenzo

On Oct 11, 10:22 am, Vibhuti Gupta <guptavibh...@gmail.com> wrote:

Vibhuti Agarwal

unread,
Oct 11, 2010, 2:44:55 PM10/11/10
to google-a...@googlegroups.com
Thanks Lorenzo. The link was very useful. 
Actually the issue was resolved when I placed the properties file in the same package where my interface was placed.

Regards
Vibhuti

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To post to this group, send email to google-a...@googlegroups.com.
To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.


Reply all
Reply to author
Forward
0 new messages