Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Contributor
PabloBB89
Posts: 13
Registered: ‎11-27-2012
My Device: BB-9300, OS6
Accepted Solution

What files include into Webwoks package

Hi, I have a doubt and I hope you guys can help me. I´m doing a webworks app. Doubt is about what files should I put in my webworks package. I have a webproject running in a server. What I would like to do is setting the xml content to the index.html which its in the server (so I can make changes without update the app). I tried this and the page displays well but I´m facing some problems:

 

1º sometimes I get error of connection and I have to close and reopen the app. (which does not´t happen if I put the index.html inside the webwork package).

2º The blackberry feature doesn't work, for example when I want to capture the back button with blackberry.system.event... throws a blackberry not defined error.

 

So, is it really necessary to put all js+html inside the webworks package to make it work fine?

BlackBerry Development Advisor
cdelcol
Posts: 37
Registered: ‎01-08-2010
My Device: Various

Re: What files include into Webwoks package

[ Edited ]

No it is not necessary. You likely have incorrect access/feature elements in your config.xml.

 

For #1, this is true. If you have network problem no content will work if you don't start at html page included with your app...it goes to the internet at startup.

For #2, you need to have an access element to allow the app to get the remote url, and you need to nest your blackberry.system feature element inside that. You likely have this at the root of the doc if it works when loaded from "local:///" location.

Retired
erikjohnzon
Posts: 245
Registered: ‎09-21-2012
My Device: Q10

Re: What files include into Webwoks package

One thing to add as Chris mentioned. If you are building your application in this manner. Consider including a manifest file such as: http://www.html5rocks.com/en/tutorials/appcache/beginner/

 

This way your application will load a cached version, and updates are pushed down when you expire them. The benefit of a WebWorks application and HTML5.

@erikjohnzon
erjohnson@blackberry.com
Contributor
PabloBB89
Posts: 13
Registered: ‎11-27-2012
My Device: BB-9300, OS6

Re: What files include into Webwoks package

[ Edited ]

Thank you for the answer, very usefull both.


Then I sould be missing something in the code since blackberry feature is not found by my app. If you dont mind take a look.

 

Its important to note that this code works fine when I put the html and js files inside of the webwork package.

 

 

<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets"
        xmlns:rim="http://www.blackberry.com/ns/widgets"
        version="2.0"
	rim:header="RIM-Widget: rim/widget">
  <author href="http://www.example.com/"
          rim:copyright="Copyright 1998-2012 My Corp">My Corp</author>
  <name>FIDS_Light</name>
  <icon src="img/icon.png"/>
  <content src="http://192.168.0.104:8080/Test_Project/"/>
  <access subdomains="true" uri="*"/>
<rim:loadingScreen    
    backgroundImage="img/imgFIDS.png"
     foregroundImage="img/ajax-loader.gif"
     onRemotePageLoad="true"
     onLocalPageLoad="true"
     onFirstLaunch="true">
</rim:loadingScreen>

<rim:allowInvoke Params="true" />
<rim:navigation mode="focus"/>

<rim:connection timeout="60000">
<id>TCP_WIFI</id>
<id>TCP_CELLULAR</id>
<id>BIS-B</id>   
<id>MDS</id>
<id>WAP2</id>
<id>WAP</id>
</rim:connection>  
<rim:cache disableAllCache="true"/>
  <feature id="blackberry.ui.dialog"/>
  <feature id="blackberry.app" required="true" version="1.0.0.0"/>
  <feature id="blackberry.app.event" required="true" version="1.0.0.0"/>
  <feature id="blackberry.system" required="true" version="1.0.0.0"/>
  <feature id="blackberry.system.event" required="true" version="1.0.0"/>
  <feature id="blackberry.identity" required="true" version="1.0.0"/>
  <feature id="blackberry.push" required="true" version="1.0.0"/>
  <feature id="blackberry.utils" required="true" version="1.0.0.0"/>
  <feature id="blackberry.invoke" required="true" version="1.0.0.0"/>
  <feature id="blackberry.io.file" required="true" version="1.0.0.0"/>
  <feature id="blackberry.io.dir" required="true" version="1.0.0.0"/>
</widget>

 The use of the blackberry.app.event is here. initPagMenu is called in the onCreate event of the page

 

in index.html:

<script>$('#pagMenu').live('pagebeforecreate',function(event){setTimeout(function () {initPagMenu();}, 200);});</script>

in javascript file:

function initPagMenu() {
blackberry.system.event.onHardwareKey(blackberry.system.event.KEY_BACK,function handleBack(){ if(location.href.indexOf("#") == -1){ blackberry.app.exit(); }else{ history.back(); }
            return false;});
}

 

BlackBerry Development Advisor
cdelcol
Posts: 37
Registered: ‎01-08-2010
My Device: Various

Re: What files include into Webwoks package

 


PabloBB89 wrote:

Thank you for the answer, very usefull both.


Then I sould be missing something in the code since blackberry feature is not found by my app. If you dont mind take a look.

 

Its important to note that this code works fine when I put the html and js files inside of the webwork package.

 

 

<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets"
        xmlns:rim="http://www.blackberry.com/ns/widgets"
        version="2.0"
	rim:header="RIM-Widget: rim/widget">
  <author href="http://www.example.com/"
          rim:copyright="Copyright 1998-2012 My Corp">My Corp</author>
  <name>FIDS_Light</name>
  <icon src="img/icon.png"/>
  <content src="http://192.168.0.104:8080/Test_Project/"/>
  <access subdomains="true" uri="*"/>

  <feature id="blackberry.ui.dialog"/>
  <feature id="blackberry.app" required="true" version="1.0.0.0"/>
  <feature id="blackberry.app.event" required="true" version="1.0.0.0"/>
  <feature id="blackberry.system" required="true" version="1.0.0.0"/>
  <feature id="blackberry.system.event" required="true" version="1.0.0"/>
  <feature id="blackberry.identity" required="true" version="1.0.0"/>
  <feature id="blackberry.push" required="true" version="1.0.0"/>
  <feature id="blackberry.utils" required="true" version="1.0.0.0"/>
  <feature id="blackberry.invoke" required="true" version="1.0.0.0"/>
  <feature id="blackberry.io.file" required="true" version="1.0.0.0"/>
  <feature id="blackberry.io.dir" required="true" version="1.0.0.0"/>
</widget>

 

 

I cut out a bunch of items in the middle. In order to have api's load properly when accessing a remote page, you'll need something like:

 

<access uri="http://<your_domain>"
    <feature id="blackberry.app" required-"true" version-"1.0.0.0" />
</access>

 if you put the feature elements at the root, there is an implied "local:///" whitelisted. Anything else you need to be explicit.