cordova-ui and gui built via programatically or ui.xml templates
milesifrr Mar 19, 2013 6:24 AMHi everybody,
I have just managed to have the cordova-quickstart demo working: the ui, the remote calls and the rest calls work fine. After experimenting somewhat with it, I have some question about how the user interface is built and managed.
In the gwt.xml module I see
<inherits name="org.jboss.errai.common.ErraiCommon"/>
<inherits name="org.jboss.errai.bus.ErraiBus"/>
<inherits name="org.jboss.errai.ioc.Container"/>
<inherits name="org.jboss.errai.enterprise.CDI"/>
<inherits name="org.jboss.errai.ui.Cordova"/>
<inherits name="org.jboss.errai.enterprise.Jaxrs"/>
and in the source code I have:
@EntryPoint
@Templated("#template")
public class App extends Composite {
private void addLabel() {
Label label = new Label("Let's see if I see it!");
label.setHeight("60px");
label.setWidth("300px");
RootPanel rootPanel = RootPanel.get();
rootPanel.add(label);
}
@AfterInitialization
public void createUI() {
RootPanel rootPanel = RootPanel.get();
rootPanel.add(this);
}
....
}
Here are some questions:
- it seems that the templating mechanism works even if I do not have <inherits name="org.jboss.errai.ui.UI" />. It is the <inherits name="org.jboss.errai.ui.Cordova"/> that does it?
- I commented all the code of the createUI() method and I still have a fully functional UI. It looks like that code is not necessary, is it?
- Because I need to build my UI from ui.xml files or from code, I deleted the @Templated("#template") annotation and in the createUI() method I left only the row of code "addLabel();". I found out that in the browser I could only see the label, as expected, while in the Android emulator I could see nothing at all (in addLabel() I even tried RootPanel rootPanel = RootPanel.get("rootPanel"), where rootPanel is a div in the index.html page, with the same results both in the browser and in the emulator). When I restored the @Templated("#template") annotation, I found out that in the browser I could see both the label and the template ui, while in the Android emulator I could see only the template ui. So I am wondering how I can install a user interface via code or ui.xml templates.
- do you know if there is a tool like the chrome inspection tool to inspect the UI in the android browser?
To sum things up, it looks like the @Templated annotations completely controls the process that sets up the UI and there is a discrepancy between the behaviour in the browser and the android emulator. How is it possible to build the ui in the "classic" ways with cordova-ui ?
thanks in advance to anybody helping me to understand how things work
ciao Francesco