Error In Internationalize a GWT UIBinder page with Messages - gwt

We are using GWT & GWTP with UiBinder and I want to use properties files for messages.
I have seen GWT app with UiBinder and This one also.
1) Entries In gwt.xml file
<extend-property name="locale" values="en"/>   
<set-property-fallback name="locale" value="en"/>
 2) In LoginView.ui.xml
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'
xmlns:fmt="ui:with:com.nextenders.client.properties.NTCommonPropeties"
ui:generateFormat='com.google.gwt.i18n.rebind.format.PropertiesFormat'
ui:generateKeys='com.google.gwt.i18n.rebind.keygen.MD5KeyGenerator'
ui:generateLocales="en">
I have created a file and interface and added in Xml.
<ui:with field='fmt' type='com.nextenders.client.properties.LocalizableResource'/>
Now I am trying to use
Now I am trying to compile with "-extra" option.
But I am getting "No resource found for key" error.
In which order need to go through all the steps described here.
I mean Should I set messages after compile.
UPDATE: I have removed
<g:Label text="{fmt.loginBoxTitle}" styleName= "login_label" />. But Still It give same error when I compile.

I have found the solution. The error "No resource found for key means GWT compiler is not able to find mapping for the key you have specified. E.g. loginBoxTitle in my {fmt.loginBoxTitle}
I have rechecked files for mappings. It worked.

Related

Can't return custom class from GWT Service

I have my GWT project, and another project that just has simple Domain Objects, and has nothing GWT specific.
In my Domain Objects project, I have a class Bob that has some primitive fields. Nothing special. He implements Serializable for the hell of it.
I wanted to return this type from a GWT service method. Learning that the service method can only return classes that implment GWT's IsSerializable interface, I created a subclass of Bob, BobSO (Bob Service Object), and had it implement IsSerializable.
Basic project structure
proj> Bob.java
proj_gwt
proj_gwt > projgwt.gwt.xml
proj_gwt.client
proj_gwt.server
proj_gwt.shared > BobSO.java
I'm getting an error when running the service. It seems that it's loading BobSO, and seeking the source for the superclass Bob, and can't find the source.
"Errors in [path to file]
Line 6: No source code is avaiable for Bob did you forget to inherit a required
Will by BobSO subclass work since he implements IsSerializable?
It looks like GWT knows where BobSO is. What do I need to do to so it knows where the source to Bob.java is? I've tried creating a gwt.xml in my DOmain Objects project, but I'm not sure if it needs to list each class that should be visible, and how to import it in my GWT project.
1. Serializability
Implement either Serializable or IsSerializable, plus make sure, that the class fulfills the remaining requirements for GWT serializability (a no-args constructor, no final fields, ...)
2. Locating the sources
You need to create a module to help GWT-RPC find the serializable classes [*].
The module "gwt.xml" can live in your domain project. Alternatively, if you you don't want to touch the domain project, it can also live in your GWT project - just make sure to put it in the correct package:
DomainProject
src
bar
domain
Bob.java
GwtProject
src
bar
Domain.gwt.xml (contains <src path='domain'/>)
foo
client
MyEntryPoint.java
shared
BobSO.java
Bar.gwt.xml (contains <src path='client'/>
<src path='shared'/>
<inherits name="foo.Domain"/>)
Important notes
Make sure to delete the gwt-unitCache folder after changing such dependencies. Otherwise, the compiler often fails in strange ways (tested with gwt 2.5.0.rc2).
Always supply the source folders to the GWT compiler for everything the client side needs to know about. In this case, this is also the source for bar.domain.Bob.
Note
It's also possible to put Domain.gwt.xml in the "bar/domain" package, and use <source path=""/>
[*] By the way, it may be surprising, that defining a module for the dependency is usually not even strictly necessary in GWT. (It is however required when GWT-RPC is involved.) Try it with a simple example, if you like - GWT will find the sources by itself - as long as they're on the GWT compiler's class path
Will by BobSO subclass work since he implements IsSerializable?
It should work, but note that IsSerializable is the "old" marker interface for GWT. You can now use java.io.Serializable instead.
It looks like GWT knows where BobSO is. What do I need to do to so it knows where the source to Bob.java is? I've tried creating a gwt.xml in my DOmain Objects project, but I'm not sure if it needs to list each class that should be visible, and how to import it in my GWT project.
I think that creating a GWT module in your domain project is the right approach. You don't have to list each class. The "path" attribute of the "source" element should contain the name of a child package:
<module>
<source path="mysubpackage" />
</module>
You can have more that one source element if you have multiple packages. You can also include/exclude specific classes from a package, e.g.:
<source path="somepackage">
<include name="SomeClass.java" />
<include name="stuff/OtherClass.java" />
<exclude name="blah/**" />
</source>
To import it in your original GWT module, simply add an "inherits" entry with the fully qualified name of the .gwt.xml file you created, but without the ".gwt.xml" extension. Assuming your new module file is called Domain.gwt.xml and is located in package "com.domainpackage", you would add:
<inherits name="com.domainpackage.Domain" />
You can package your project as a jar and add it to the class path of your GWT project.

Internationalization in Google Web Toolkit

I want to use the internationalization for my GWT Application.
I read that i need a Languages.properties file in which I write for example ticketHomeSiteLabelDemnaechst="Activities due soon"
a class which i called Languages.java:
import com.google.gwt.i18n.client.Messages;
public interface Languages extends Messages{
String ticketHomeSiteLabelDemnaechst();
}
applicationname.gwt.xml:
<inherits name='com.google.gwt.i18n.I18N'/>
<extend-property name="locale" values="de"/>
<extend-property name="locale" values="en"/>
<set-property-fallback name="locale" value="en"/>
And in the class where I want to use it:
final Languages language = GWT.create(Languages.class);
labelDemnaechst.setText(Int.get(language.ticketHomeSiteLabelDemnaechst()));
When I do this:
I get this error: No source code is available for type Languages; did you forget to inherit a required module?
The error message indicates that Languages.java may be in the wrong package. Make sure it is in the client package, assuming that is where you keep your other gwt code (the EntryPoint, and whatever the last code snippet came from).

How do I tell GWT to not compile a permutation for gears

I have included gwt-html5-geolocation into my GWT project and was disappointed to find that it doubled up on my number of permutations compiled. Apparently if the browser does not support geolocation API then it falls back to use gears to find out your location. Is there a way to NOT compile a permutation for gears similar to the way you can tell GWT to only compile certain browser permutations? (the geolocation stuff is very much a nice-to-have and frankly if the client is running an old browser then I am happy not to get their location)
Thanks
Looking at Html5Geolocation.gwt.xml, you could add
<inherits name="com.google.code.gwt.geolocation.Html5Geolocation" />
<set-property name="geolocation.api" value="html5" />
which would completely disable the gears property value.

Mapping ui:field in GWT to generated code

I'm trying to get some automated UI testing going on a GWT application and I'm having trouble finding a way to track UI elements.
For example, I have the following:
<g:Button text="Submit" ui:field="submitButton" enabled="true" />
which generates:
<button class="gwt-Button" type="button">Submit</button>
Its a compiler error to set both ui:field and id (id is considered deprecated anyway) so the problem is that I have no easy way to select my submit button using something like selenium.
Is anyone aware of a way I can map the
ui:field="sumbitButton"
to the generated HTML?
After further investigation I've discovered that you can enable debugIds which are ment for testing purposes. If you add:
<inherits name="com.google.gwt.user.Debug"/>
to your *.gwt.xml file you can then set debugId on your ui elements as such:
<g:Button text="Submit" ui:field="submitButton" enabled="true" debugId="submitButton"/>
and also in the codebehind by using the ensure debug id method
submitButton.ensureDebugId("submitButton");

JSF Validation not finding custom ResourceBundle class

I have a custom ResourceBundle class org.example.web.UILabels.java which works well in running code but the JSF editor in Eclipse is not finding it, I assume the editor/validator is only looking for properties files by the name. This also means I no longer get type ahead find on the resources which was very nice to have.
Any ideas how this could be rectified?
<f:loadBundle basename="org.example.web.UILabels" var="uiLabels"/>
...
<h:outputText value="#{uiLabels.someTextValue}" />
...
I am getting the error message (in the problems error list)
Resource bundle org.example.web.UILabels cannot be found on classpath
Type=JSF Problem
Eclipse3.4.0 with WebStandardTools Versions
Version:1.4.0.v200802280619-13-7w311917141518
Version:1.5.1.v200802280619-1407w311917141519
Version:3.0.0.v200806092130-7A-8Y8QqN2lf4VSWrI2ek5Pf4k7s
For more about why I am using a ResourceBundle class instead of just a properties file see Question 653682 how-to-override-some-resources-from-a-propertyresourcebundle
Thanks for your time, David Waters
The resource-bundle element is more efficient than the f:loadBundle action since the bundle can be created once for teh entire application. However its a JSF 1.2 feature and if u want to be compatible with JSF 1.1 you must use JSF 1.1. Heres an example if your using JSF 1.2:
Define it in your faces-config.xml like this:
<application>
<resource-bundle>
<base-name>org.example.web.UILabels</basename>
<var>uiLabels</var>
</resource-bundle>
</application>
Sorry for not answering your question, but I dont have first hand experience with Eclipse. I also misunderstood your question first, therefor Ive edited my original answer.
I had the same problem, I finally find this sollution :
Eclipse search only the default properties, your project has to have a properties with no locale, for example, with :
<f:loadBundle basename="i18n.messages" var="msg" />
Eclipse will only search "i18n/messages.properties".