App用HTML,CSS和Javascript写成,之后被扩展成桌面的(Windows,Mac,Linux),互联网的(Facebook等),本地移动设备上的(iOS,Android,RIM和Windows Phone)应用程序。开发者还能把一些流行的Javascript构架如jQuery Mobile,Sencha和Dojo整合到Worklight中。而且App的本地运行时也能用本地代码来编写和修改。
news-impl.js
function getStories(interest) {
path = getPath(interest);
var input = {
method : 'get',
returnedContentType : 'xml',
path : path
};
return WL.Server.invokeHttp(input);
}
function getStoriesFiltered(interest) {
path = getPath(interest);
var input = {
method : 'get',
returnedContentType : 'xml',
path : path,
transformation : {
type : 'xslFile',
xslFile : 'filtered.xsl'
}
};
return WL.Server.invokeHttp(input);
}
function getPath(interest) {
if (interest == undefined || interest == '') {
interest = 'gn';
}
return '/special/00011K6L/rss_' + interest + '.xml';
}
News.xml
<connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
<protocol>http</protocol>
<domain>news.163.com</domain>
<port>80</port>
<!-- Following properties used by adapter's key manager for choosing specific certificate from key store
<sslCertificateAlias></sslCertificateAlias>
<sslCertificatePassword></sslCertificatePassword>
-->
</connectionPolicy>
index.html<ul id="news" data-role="listview">
</ul>
main.js
var invocationData = {
adapter : 'news',
procedure : 'getStoriesFiltered',
parameters : ['gn']
};
WL.Client.invokeProcedure(invocationData, {
onSuccess : getNationListSuccess,
onFailure : getNationListFailure
});
function getNationListSuccess(response)
{
var items = response.invocationResult.Items;
for (var i = 0; i < items.length; i++)
{
$("#news").append('<li><a href="' + items[i].link + '">' + items[i].title + '</a></li>');
$("#news").listview("refresh");
}
}
function getNationListFailure(response)
{}
几种大小的图标分别放置在项目的res目录下的几个子目录中,目录和图标大小分别是: