Unable to remove this error, nothing is working although the same code is working fine on other systems.
"com.pariter.client.Button can not be found in source packages. Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly."
Adding Button Class from Comment.
package com.pariter.client;
class Button extends com.google.gwt.user.client.ui.Button {
public Button(String s) {
super(s);
this.setPixelSize(100, 25);
this.addStyleName("button");
}
}
Adding Entry Point and Source Path Sections for .gwt.xml from comment
...
<!-- Specify the app entry point class. -->
<entry-point class='com.pariter.client.LoginPage'/>
<!-- Specify the paths for translatable code -->
<source path='client'/>
<source path='shared'/>
</module>
If I recall correctly, this error would occur if the com.pariter.client.Button is not in a package (or subpackage) defined in your .gwt.xml.
Check your .gwt.xml. i.e.
...
<entry-point class='com.pariter.AppEntryPoint'/>
<source path="client"/>
...
</module>
[Update]
You will either need to move your com.pariter.client.LoginPage Entry Point to com.pariter.LoginPage (and therefore update your .gwt.xml) or move your Button class to the package com.pariter.client.client
Related
I am using the ZK framework and have created a maven project of custom components.
I am trying to include static CSS for the project (for components with no javascript) as per the brief outline on this page:
http://books.zkoss.org/wiki/ZK_Component_Development_Essentials/Packing_as_a_Jar
How does zk know to include the CSS generated when the project is included in a ZK WEB project ? Currently my resources directory of my component project looks like this:
web
foo
bar
css
zk.wcs
macro.css.dsp
other.css.dsp
less
macro.less
other.less
My zk.wcs :
<css language="xul/html">
<stylesheet href="~./foo/bar/css/macro.css.dsp"/>
<stylesheet href="~./foo/bar/css/primitive.css.dsp"/>
</css>
My styles in macro.css.dsp are not applied when using the component project in my web zk project however...
You can include css in lang-addon.xml:
<!-- define a component -->
<component>
<!-- the tag name of this component
required,
must be unique -->
<component-name>codemirror</component-name>
<!-- fully-qualified java class name at server side
required for a new component that not extends another component -->
<component-class>org.sinnlabs.zk.ui.CodeMirror</component-class>
<!-- widget class, 'org.sinnlabs.zk.ui.CodeMirror' also specify the
package of widget class 'org.sinnlabs.zk.ui'
required for a new component that not extends another component -->
<widget-class>org.sinnlabs.zk.ui.CodeMirrorWidget</widget-class>
<!-- mold
required for a new component that not extends another component
or has self widget-class
a mold denotes the files that to render and style this comopnent -->
<mold>
<!-- default mold is required -->
<mold-name>default</mold-name>
<!-- relative path based on widget-class' path
(web/js/org/sinnlabs/zk/ui/)
where codemirrorwidget.js (required) contains a function that
will render the html of the comopnent. -->
<mold-uri>mold/codemirrorwidget.js</mold-uri>
<css-uri>css/codemirror.css</css-uri>
</mold>
</component>
zk.load will load your css style.
Im looking to load a different user interface in my GWT application if the user is accessing from a mobile web browser or desktop web browser. I was wondering how I would edit my Application.gwt.xml file change which entry point class is loaded based on the the form factor. I thought it might be something along these lines but i'm kind of just hacking so I was wondering if anyone had any ideas?
<entry-point class="webapp.client.WebAppEntryPoint">
<when-property-is name="formfactor" value="desktop"/>
</entry-point>
<entry-point class="webapp.client.MobileAppEntryPoint">
<when-property-is name="formfactor" value="mobile"/>
</entry-point>
Cheers.
Its almost as easy as you describe it -- that is, once you have worked out the formfactor property and how to pick a value for it.
It turns out that when you create an entrypoint and declare it in your module, the compiler uses GWT.create to actually make an instance of it. This leaves it subject to the rebind rules declared in your module. So if both WebAppEntryPoint and MobileAppEntryPoint inherit from some common superclass, you can declare that entrypoint in the module, and a slight varient on the rules you made to trigger them to be selected:
<entry-point class="webapp.client.AbstractAppEntryPoint" />
<replace-with class="webapp.client.WebAppEntryPoint">
<when-type-is class="webapp.client.AbstractAppEntryPoint" />
<when-property-is name="formfactor" value="desktop"/>
</entry-point>
<replace-with class="webapp.client.MobileAppEntryPoint">
<when-type-is class="webapp.client.AbstractAppEntryPoint" />
<when-property-is name="formfactor" value="mobile"/>
</entry-point>
These rules state: "When GWT tries to start the app, use AbstractEntryPoint (which implements EntryPoint) to do so. When someone invokes GWT.create(AbstractEntryPoint) and formfactor is desktop, give them a WebAppEntryPoint instance. When someone invokes GWT.create(AbstractEntryPoint) and formfactor is mobil, give them a MobileAppEntryPoint instance.
This then leaves the hard part - how do you build the formfactor property, define the possible values, and let the app pick the right one on startup?
To help answer this, lets look at two standard properties that already existing in GWT - locale and user.agent. Useragent detection is managed in the com.google.gwt.useragent.UserAgent module - properties are defined, a way to select a property is listed, and some helpful 'make sure that this wiring worked' bits are added to the app. Possible locales are started in com.google.gwt.i18n.I18N, but are designed to be extended within your own app. There is lots of extra stuff in here as well, defining how to pick which locale should be activated. We'll want to steal the idea of pre-defining the possible formfactors from user.agent, and will want the idea of reading the right formfactor from the locale code.
First, define the property.
<define-property name="formfactor" values="desktop, mobile" />
In this example, we'll only allow these two possible values - in reality, you might want desktop (i.e. large and mouse/keyboard), tablet (large and touch), phone (small and touch), or some other variation on this.
Next, decide how to read the right property value. There are two basic ways to do this - via a simple snippet of javascript, written in your module file, and by writing a class that generates JavaScript, based on some configuration settings. I'm going to go with the simplest one first, and let you work out how to actually detect this detail in javascript (update the question or comment if you can clarify further what you have/need/expect):
<!-- borrowing/adapting from
http://code.google.com/p/google-web-toolkit/wiki/ConditionalProperties -->
<property-provider name="formfactor"><![CDATA[
{
var ua = window.navigator.userAgent.toLowerCase();
if (ua.indexOf('android') != -1) { return 'mobile'; }
if (ua.indexOf('iphone') != -1) { return 'mobile'; }
return 'desktop';
}
]]></property-provider>
Again, this goes in the module, and defines some simple JavaScript to pick the value for formfactor - if the useragent contains the string 'android' or 'iphone', activate the mobile value, otherwise activate desktop. This code will be placed in your .nocache.js file, and used to pick the right permutation (with the right entrypoint, as defined above).
Apart from Colin's detailed answer you might have a look at GWT's standard example for mobilewebapp - http://code.google.com/p/google-web-toolkit/source/browse/#svn%2Ftrunk%2Fsamples%2Fmobilewebapp
The example FormFactor.gwt.xml - http://code.google.com/p/google-web-toolkit/source/browse/trunk/samples/mobilewebapp/src/main/java/com/google/gwt/sample/mobilewebapp/FormFactor.gwt.xml
You can use replace with
<replace-with class="webapp.client.MobileAppEntryPoint">
<when-type-is class="webapp.client.WebAppEntryPoint" />
<any>
<when-property-is name="formfactor" value="mobile"/>
</any>
</replace-with>
NOTE :i am not tried with entry point class ..but working fine for some Widget classes
For details refer Gwt differed binding
SOLVED:
Okay, thanks to everyone who replied. I used a little bit of everyones answer to get to the solution! Firstly I followed SSRs and had a look at the example FormFactor.gwt.xml file. I copied this into my project and referred to it in my App.gwt.xml file. I then followed Colins and added the following code to my App.gwt.xml file in order to load a different EntryPoint based upon form factor:
<entry-point class="webapp.client.AbstractEntryPoint" />
<replace-with class="webapp.client.WebAppEntryPoint">
<when-type-is class="webapp.client.AbstractEntryPoint" />
<when-property-is name="formfactor" value="desktop"/>
</replace-with>
<replace-with class="webapp.client.MobileAppEntryPoint">
<when-type-is class="webapp.client.AbstractEntryPoint" />
<when-property-is name="formfactor" value="mobile"/>
</replace-with>
I have a problem with internationalization. I'm trying to implement support two languages in my GWT application. Unfortunately I never found a complete example how to do it with the help of UiBinder. That is what I did:
My module I18nexample.gwt.xml:
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='i18nexample'>
<inherits name="com.google.gwt.user.User" />
<inherits name='com.google.gwt.user.theme.clean.Clean' />
<inherits name="com.google.gwt.i18n.I18N" />
<inherits name="com.google.gwt.i18n.CldrLocales" />
<entry-point class='com.myexample.i18nexample.client.ExampleI18N' />
<servlet path="/start" class="com.myexample.i18nexample.server.StartServiceImpl" />
<extend-property name="locale" values="en, fr" />
<set-property-fallback name="locale" value="en" />
</module>
My interface Message.java:
package com.myexample.i18nexample.client;
import com.google.gwt.i18n.client.Constants;
public interface Message extends Constants {
String greeting();
}
The same package com.myexample.i18nexample.client has three properties file:
Message.properties:
greeting = hello
Message_en.properties:
greeting = hello
Message_fr.properties:
greeting = bonjour
My UiBinder file Greeting.ui.xml:
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder
xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
ui:generateFormat="com.google.gwt.i18n.rebind.format.PropertiesFormat"
ui:generateKeys="com.google.gwt.i18n.rebind.keygen.MD5KeyGenerator"
ui:generateLocales="default" >
<ui:with type="com.myexample.i18nexample.client.Message" field="string" />
<g:HTMLPanel>
<ui:msg key="greeting" description="greeting">Default greeting</ui:msg>
</g:HTMLPanel>
</ui:UiBinder>
When the application starts, I always get the output in the browser:
Default greeting
Why? What am I doing wrong?
I tried to run the application from different URL:
http://127.0.0.1:8888/i18nexample.html?gwt.codesvr=127.0.0.1:9997
http://127.0.0.1:8888/i18nexample.html?locale=en&gwt.codesvr=127.0.0.1:9997
http://127.0.0.1:8888/i18nexample.html?locale=fr&gwt.codesvr=127.0.0.1:9997
The result does not change. Although I expected in last case a message bonjour.
If for example I use a g:Buttton instead of the message ui:msg:
<g:HTMLPanel>
<g:Button text="{string.greeting}" />
</g:HTMLPanel>
Then I get as a result of the button with text "hello"
And if I enter the URL:
http://127.0.0.1:8888/i18nexample.html?locale=fr&gwt.codesvr=127.0.0.1:9997
The text on the button changes to "bonjour". Here everything works as expected. But why internationalization is not working in my first case?
And whether there is a difference between the following:
<ui:msg description="greeting">Default greeting</ui:msg>
<ui:msg description="greeting">hello</ui:msg>
<ui:msg description="greeting"></ui:msg>
Should there be different results in these cases? How to write properly?
Please explain to me the principles of internationalization in GWT and why my example does not work.
Any suggestions would be greatly appreciated.
First, the files should be named Message_fr.properties (resp. Message_en.properties), not Message.properties_fr (resp. Message.properties_en).
Then ui:msg et al. in UiBinder will generate an interface (extending com.google.gwt.i18n.client.Messages)), not use one that you defined. For that, you have to use {string.greeting} (where string is the ui:field you gave to your ui:with). The UiBinder generator will do a GWT.create() on the type class of your ui:with, which is what you'd have done in Java code:
Message string = GWT.create(Message.class);
String localizedGreeting = string.greeting();
In the implicit Messages interface (generated by UiBinder), the various ui:generateXxx attributes on the ui:UiBinder will be transformed into annotations on the interface (properties of the #Generate annotation, or the value of the #GenerateKeys annotation).
Then, one method will be generated for each ui:msg, where the attributes generate equivalent annotations (#Key, #Description) and the content of the ui:msg element is the value of the #DefaultMessage annotation. When you have or widgets inside the content, they'll be turned into arguments to the method and placeholders in the #DefaultMessage text (the values will be filled by UiBinder).
I'd suggest you make something working without UiBinder first, and understand how it works; then try the ui:msg in UiBinder, using -gen in DevMode or the compiler so you can see exactly what code does UiBinder generate (yes, it really only generates code that you could have written yourself by hand).
Also, you should add a <set-property name="locale" value="en, fr" /> or you'll still have the default locale around, despite the set-property-fallback (it'd just never be used)).
I have to rewrite the core cache model. And this doesn't work. My first attempt to solve the problem was to try the rewrite with another model...
In my config.xml I declared the following
<global>
<models>
<core>
<rewrite>
<**layout**>MyCompany_MyModule_Model_Core_Cache</**layout**>
</rewrite>
</core>
</models>
....
and in my class I died in the consturctor.
This works perfectly!
So my may in rewriting models is the right one.
But If I don't use the layout-node in the xml but using the cache-node instead this does not work.
So my attempt is the following and this is not working:
<global>
<models>
<core>
<rewrite>
<cache>MyCompany_MyModule_Model_Core_Cache</cache>
</rewrite>
</core>
</models>
....
My question now: is there a way to rewrite / overload the "cache-core-model"???
The cache will be initialized before module configurations (config.xml) are loaded. The cache-Model was instanciated with Mage::getModel, which caches the modelnames in the registry.
So all later tries to get the custom cache-model will also fail.
Solution: put this rewrite statement in the etc/local.xml. This is a bit dirty because the local.xml should only hold module independent stuff. But this is better than copying core files to local.
I had the same question, but my solution is a little bit different to yours ;-)
Magento will load the XML file from /app/etc/*.xml (this files will not be cached) before everything else in magento.
So i created my own file here "cache.xml" and the content is
<?xml version="1.0"?>
<config>
<global>
<models>
<core>
<rewrite>
<cache>MyCompany_MyModule_Model_Core_Cache</cache>
</rewrite>
</core>
</models>
</global>
</config>
works perfect in 1.6,1.7 and 1.8
I'm also trying to do the same thing and i don't think it's possible. If you var_dump out $this->_xml->group->models in the method: getGroupedClassName (app/code/core/Mage/Core/Model/Config.php) you'll notice that your rewrite it's not yet available, hence why it's skipped.
If you try to overwrite translate or layout: your_class_model you'll notice that the $this->_xml... dumps the initial core classes (with no rewrite) and you'll see your rewrite down the line well past the core/cache. So, it's probably being overridden but the class is already instantiated, set up and used; so it's really not going to fire anything.
Hence i don't think it's possible to override the core/cache. You'll have to move it to the app/code/local. Pitty.
I'm trying to internationalize a test application with GWT following the instruction and I have:
com.example.client.MyConstants.java
com.example.client.MyConstants_en.properties
com.example.client.MyConstants_fr.properties
com.example.client.MyAppEntryPoint.java
In this code I have:
public interface MyConstants extends Constants
{
#DefaultStringValue("HelloWorld")
String hellowWorld();
}
And
public class MyAppEntryPoint implements EntryPoint
{
public void onModuleLoad()
{
MyConstants constants = GWT.create(MyConstants.class);
VerticalPanel mainPanel = new VerticalPanel();
mainPanel.add(new Label(constants.hellowWorld()));
RootPanel.get("myContainer").add(mainPanel);
}
}
For MyApp.gwt.xml I have:
<module rename-to="myModule">
<inherits name="com.google.gwt.xml.XML" />
<inherits name="com.google.gwt.i18n.I18N"/>
<inherits name='com.google.gwt.user.theme.standard.Standard'/>
<!-- Specify the app entry point class. -->
<entry-point class='com.example.client.MyAppEntryPoint'/>
<extend-property name="locale" values="en,fr"/>
</module>
In the html I have:
...
It all seems to work as long as I don't include in the xml file. As soon as I do, I get the following exception:
[ERROR] Generator 'com.google.gwt.i18n.rebind.LocalizableGenerator' threw threw an exception while rebinding 'com.example.client.myConstants'
java.lang.NullPointerException: null
...
Any help would be greatly appreciated on why it's throwing the exception.
-
The answer is that the module name has to be the same as the properties name. So if I use:
<module rename-to="MyApp">
Then the properties files need to be:
com.example.client.MyAppConstants.java
com.example.client.MyApp_en.properties
com.example.client.MyApp_fr.properties
In other words, the module name has to be the same as the properties files.
It could be the extend-property doesn't accept multiple values. I think you should write:
<extend-property name="locale" values="en"/>
<extend-property name="locale" values="fr"/>
After trying different options I figured, you don't need "en" option, I guess because that is the default hence you need:
com.example.client.MyAppConstants.java (Interface)
com.example.client.MyAppConstants.properties (Default)
com.example.client.MyAppConstants_fr.properties (Other language)
Hopefully this helps someone else's time.