Try to point exactly property file with @Key

2010/1/25 Ashish Khivesara <[email protected]>

> Hi I am trying to do a simple constant lookup. 
> com.google.gwt.i18n.client.Constants
> is what I need to use.
>
> I created the interface
>
> public interface PhotoConstants extends Constants{
>
> String appName();
> }
>
> I am calling is in GWT Entry Point code as follows
>
> PhotoConstants constants =
> (PhotoConstants)GWT.create(PhotoConstants.class);
> Window.alert(constants.upnpAppName());
>
> I created a PhotoConstants.properties file in war/ directory.
>
>
> However I get the following Exception.
>
> This maybe because I dont have the properties file in the correct
> location?? The documentation does not say anything about it though...
>
>
> 12:57:20.298 [ERROR] [phototrial] No resource found for key 'upnpAppName'
> com.google.gwt.i18n.rebind.AbstractResource$MissingResourceException: No
> resource found for key 'upnpAppName'
>     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)
>     at
> com.google.gwt.i18n.rebind.LocalizableGenerator.generate(LocalizableGenerator.java:121)
>     at
> com.google.gwt.i18n.rebind.LocalizableGenerator.generate(LocalizableGenerator.java:98)
>     at
> com.google.gwt.dev.javac.StandardGeneratorContext.runGenerator(StandardGeneratorContext.java:418)
>     at
> com.google.gwt.dev.cfg.RuleGenerateWith.realize(RuleGenerateWith.java:38)
>     at
> com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.tryRebind(StandardRebindOracle.java:108)
>     at
> com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.rebind(StandardRebindOracle.java:54)
>     at
> com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:154)
>     at
> com.google.gwt.dev.shell.ShellModuleSpaceHost.rebind(ShellModuleSpaceHost.java:119)
>     at com.google.gwt.dev.shell.ModuleSpace.rebind(ModuleSpace.java:531)
>     at
> com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:414)
>     at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:39)
>     at com.google.gwt.core.client.GWT.create(GWT.java:98)
>     at
> com.ashish.phototrial.client.PhotoTrial.onModuleLoad(PhotoTrial.java:57)
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>     at java.lang.reflect.Method.invoke(Unknown Source)
>     at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:369)
>     at
> com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:185)
>     at
> com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:380)
>     at
> com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222)
>     at java.lang.Thread.run(Unknown Source)
>
>
>
> On Mon, Oct 26, 2009 at 8:55 PM, Sanjeev Kulkarni <[email protected]>wrote:
>
>>
>> Hi,
>> It is possible. create a java file which is like below
>>  public interface LoginConstants  extends
>> com.google.gwt.i18n.client.Messages{
>>       @DefaultMessage("Logging in..")
>>        @Key("loggingIn.msg")
>>        String loggingIn_msg();
>> }
>> And in the .properties file u just have to access this like below
>>
>> loggingIn.msg = Logging in..
>>
>> This works fine...
>>
>> On Oct 27, 9:48 am, rjcarr <[email protected]> wrote:
>> > You've already been answered, but I'll elaborate a bit.
>> >
>> > I'm going to assume you mean reading a property file in the client.
>> > If you mean reading a property file in the server then you should look
>> > at java.util.Properties.
>> >
>> > If you don't want to set up a service to obtain the contents of this
>> > properties file then you're going to need to have something on the
>> > server parse it (see java.util.Properties above), and then write the
>> > contents dynamically (say, with JSP) into the client page so that your
>> > GWT javascript can access it.
>> >
>> > As others have pointed out, you can then use Dictionary to pick up the
>> > values you're after (although I prefer to use JSNI and avoid using a
>> > Dictionary).  I haven't used Constants before, but it looks
>> > interesting ... that might be an easier route.
>> >
>> > Good luck!
>> >
>> > On Oct 26, 9:04 am, Praveen Prabakaran <[email protected]> wrote:
>> >
>> > > Hi,
>> >
>> > > There's a URL in my GWT application which is hard-coded in a java
>> > > file. I need to change this by creating a property file which contains
>> > > the URL in the form of a key-value pair. But I'm not able to do so. Is
>> > > this a limitation in GWT? Can I not use GWT to read from a property
>> > > file and print it? .Also please let me know how to include a external
>> > > package (for eg. "com.google.gwt.core.ext.typeinfo") in GWT.
>> >
>> > > Warm Regards,
>> > >    Praveen.
>> --~--~---------~--~----~------------~-------~--~----~
>> You received this message because you are subscribed to the Google Groups
>> "Google Web Toolkit" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]<google-web-toolkit%[email protected]>
>> For more options, visit this group at
>> http://groups.google.com/group/google-web-toolkit?hl=en
>> -~----------~----~----~----~------~----~------~--~---
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-web-toolkit%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>



-- 
Regards,
Alexander

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to