Worklight 6.1 Android Applicaiton renders all views with no widgets

孤街浪徒 提交于 2019-12-02 04:36:28
Idan Adar

Worklight 6.1 uses Dojo v1.9.1-20130926, not v1.8.
You can verify this in the dojoLib created for you when adding Dojo to a Worklight project. There is a version.txt file.

There is one relevant error from the LogCat: scriptError dojo.js:21
Most relevant past questions:

I do not know if the 1.8 was a typo or not, but I would suggest to start afresh with a new Worklight project, following my example below. If this is now working, I suggest to continue onwards from there.


This is what I've done. Let me know if you're doing anything else in specific:

  1. Created a new Worklight project and application; used the wizard to add the Dojo library
  2. Added the iPhone environment (while you've added Android, this is not environment-specific)
  3. Added the following Dojo widgets: Heading, Button, TextBox, Slider, Carousel, CarouselItem...

    In common\js\main.js, dojoInit() is auto-updated with the required modules in the require function:

    function dojoInit() {
      require([ "dojo/ready", "dojo/parser", "dojox/mobile", "dojo/dom", 
      "dijit/registry", "dojox/mobile/ScrollableView",
      "dojox/mobile/Button", "dojox/mobile/Heading", "dojox/mobile/TextBox",   
      "dojox/mobile/Carousel", "dojox/mobile/CarouselItem", "dojox/mobile/SearchBox", 
      "dojox/mobile/Slider"], >
    
     function(ready) {
          ready(function() {
          });
      });
    }
    
  4. Run As > Run on Worklight Development Server
  5. Preview in Worklight Console's MBS
  6. Open in Xcode
  7. Run on iOS Simulator and/or device

In both the MBS and simulator/device, I see the same:

MBS:

iOS Simulator/device:

Now if I go to the Dojo Library Requests view and uncheck Provide Missing Dojo Resources and re-run in Xcode, the graphics will then not load. If I re-check the option and re-run in Xcode, the graphics then load again.

Missing graphics:

To correct this I needed to re-build the project in Eclipse.
Why?

When building with Provide Missing Dojo Resources checked, you will find the following in the HEAD of the generated HTML: <script data-dojo-config="isDebug: false, async: true, parseOnLoad: true, mblHideAddressBar: false" src=http://some-ip-address-and-path/dojo/dojo.js" type="text/javascript"></script>

This src URL tells the application to get all Dojo resources from the dojoLib library in the server.
When unchecking Provide Missing Dojo Resources and re-building the project in Eclipse, the src URL changes to dojo/dojo.js, meaning all resources will be taken from whatever is included in the Dojo library inside the application.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!