WebView and it's File property

Hi everyone,

I’m trying to load WebView content via File property and in case I use relative path, it work fine. However, in case I create observable with the same path, it says that page cannot be loaded. HTML page is a part of app (assets directory).

Here is an example of working example without observable:

// ... other app content ...

var Observable = require("FuseJS/Observable");

var pages = Observable(
    {name: "page1", path: "assets/page1.html"},
    {name: "page2", path: "assets/page2.html"}

module.exports = {
    pages: pages

// ... other app content ...

<Each Items={pages}>
    <Page name="{name}">
        <WebView File="assets/page1.html" />

// ... other app content ...

Example above will work perfectly, however in case I use <WebView File="{path}" /> instead, it says Couldnt open file: assets/page1.html.

So basically, it looks like the actual path is known, but File property is not able to accept value from Observable.

Any ideas how to make this working?

Thank you in advance for any advise.

Hi Marek

The File property is a bit magical, as file paths used in it helps determine which files are actually bundled with the application when it’s built. For this reason, using a dynamic path via a databinding (not able to be checked at compiletime) will not make Fuse include the designated file, and thus it cannot be found at runtime.

This issue touches on several APIs, and we are currently considering different ways to define manually which assets you want assembled while retaining file names (necessary for HTML hyperlinking - Fuse currently mangles asset file names during assembly).

Until we have such a method ready, there’s unfortunately no straightforward way to embed a set of intact web pages short of manually copying them into the generated project before final build, for instance under .build/Android-debug/res/raw and using urls in the form of file://android_res/raw/my_page.html.

Hi Andreas,

As long as there is a way (even if it’s more complicated way), I can move on.

I’ll then try to use this way until any other/easier is available.

Thank you very much for your response and explanation - I really appreciate it!