我正在使用mobilefirst studio 6.3.0,这是一个调用SQL适配器的混合移动第一个应用程序。
要显示数据的HTML页面是:
<script>
$.getScript(path + "js/report.js");
</script>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css">
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
<div data-role="header">
<a href="#" data-role="button" onclick="currentPage.back();">Back</a>
<!-- <input type="button" class="appButton" value="Back" id="LoadBackButton" onclick="currentPage.back();" /> -->
<h1>Pocket Doctor</h1>
<!-- <input type="button" class="appButton" data-role="button" value="User" id="LoadUserButton" onclick="currentPage.user();" /> -->
<a href="#" data-role="button" onclick="currentPage.user();">User</a>
</div>
<div data-role="content" style="padding: 15px">
<!--application UI goes here-->
Welcome to Pocket Doctor! This is report page.
</div>
<div data-role="footer">
<div data-role="navbar">
<ul>
<li><input type="button" class="appButton" data-icon="arrow-r" value="Reservation" id="LoadReservationButton" onclick="currentPage.ReservationClick();" /></li>
<li><input type="button" class="appButton" data-icon="arrow-r" value="Report" id="LoadReservationButton" onclick="currentPage.ReportClick();" /></li>
<li><input type="button" class="appButton" data-icon="arrow-r" value="Payment" id="LoadReservationButton" onclick="currentPage.PaymentClick();" /></li>
<li><input type="button" class="appButton" data-icon="arrow-r" value="Consultation" id="LoadReservationButton" onclick="currentPage.ConsultationClick();" /></li>
</ul>
</div>
</div>
客户端js文件是:
currentPage={};
currentPage.init = function() {
WL.Logger.debug("report :: init");
};
currentPage.user = function() {
WL.Logger.debug("report :: loadUserProfilePage ");
pagesHistory.push(path + "pages/report.html");
$("#pagePort").load(path + "pages/" + "userProfile.html");
};
currentPage.ReservationClick = function() {
WL.Logger.debug("report :: loadReservationPage ");
pagesHistory.push(path + "pages/report.html");
$("#pagePort").load(path + "pages/" + "reservation.html");
};
/*currentPage.ReportClick = function() {
WL.Logger.debug("report :: loadReportPage ");
pagesHistory.push(path + "pages/report.html");
$("#pagePort").load(path + "pages/" + "report.html");
};*/
currentPage.PaymentClick = function() {
WL.Logger.debug("report :: loadPaymentPage");
pagesHistory.push(path + "pages/report.html");
$("#pagePort").load(path + "pages/payment.html");
};
currentPage.ConsultationClick = function() {
WL.Logger.debug("report :: loadConsultationPage");
pagesHistory.push(path + "pages/report.html");
$("#pagePort").load(path + "pages/consultation.html");
};
currentPage.back = function(){
WL.Logger.debug("Login :: back");
$("#pagePort").load(pagesHistory.pop());
};
currentPage.ReportClick=function()
{
var invocationData = {
adapter : 'FetchReportInfo',
procedure : 'procedure1',
parameters : []
};
WL.Client.invokeProcedure(invocationData,{
onSuccess : loadSQLQuerySuccess,
onFailure : loadSQLQueryFailure
});
};
function loadSQLQuerySuccess(result){
WL.Logger.debug("Retrieve success" + JSON.stringify(result));
displayFeeds(result);
}
function loadSQLQueryFailure(result){
WL.Logger.error("Retrieve failure");
}
function displayFeeds(result){
var input= $('LoadReservationButton');
for (var i = 0; i <result.invocationResult.resultSet.length; i++) {
var li = $('<li/>').html(result.invocationResult.resultSet[i].Category);
li.append($('<li/>').html(result.invocationResult.resultSet[i].result));
li.append($('<li/>').html(result.invocationResult.resultSet[i].ActualRange));
li.append($('<hr>'));
input.append(li);
}
}
调用结果为:
{
"isSuccessful": true,
"resultSet": [
{
"ActualRange": "120\/80",
"Category": "Blood Pressure",
"result": "100\/60"
},
{
"ActualRange": "60-100",
"Category": "Heart Rate",
"result": "58"
},
{
"ActualRange": "12-16",
"Category": "Respiration Rate",
"result": "12"
},
{
"ActualRange": "98.6F",
"Category": "Temperature",
"result": "98.6F"
},
{
"ActualRange": "70-85mg\/dL",
"Category": "Glucose",
"result": "68mg\/dL"
},
{
"ActualRange": "180-200mg\/dL",
"Category": "Cholesterol",
"result": "170mg\/dL"
},
{
"ActualRange": "<100mg\/dL",
"Category": "LDL",
"result": "80mg\/dL"
},
{
"ActualRange": "40-59mg\/dL",
"Category": "HDL",
"result": "45mg\/dL"
},
{
"ActualRange": "4.5-5.7%",
"Category": "Himoglobin[A1C]",
"result": "4%"
},
{
"ActualRange": "300-400Ug\/dL",
"Category": "DHEA",
"result": "400ug\/dL"
},
{
"ActualRange": "0-2.6ng\/mL",
"Category": "PSA[Prostate- Specific Antigen]",
"result": "2.5ng\/dL"
},
{
"ActualRange": "<7.2umol\/L",
"Category": "Homocysteine",
"result": "6.2umol\/L"
},
{
"ActualRange": "0.35-2.1mu\/L",
"Category": "Thyroid Stimulating Harmone[TSH]",
"result": "1.1mU\/L"
},
{
"ActualRange": "120-175g\/L",
"Category": "HGB",
"result": "130"
},
{
"ActualRange": "3.5-11*10^9\/L",
"Category": "WBC",
"result": "4.5*10^9\/L"
},
{
"ActualRange": "140-450*10^9\/L",
"Category": "PLT",
"result": "300*10^9\/L"
},
{
"ActualRange": "31-53%",
"Category": "HCT",
"result": "43%"
},
{
"ActualRange": "normal",
"Category": "ECG",
"result": "normal"
}
]
}
adapter-impl.js是:
var procedure1Statement = WL.Server.createSQLStatement
("SELECT report.Category, userreport.result, report.ActualRange "+
"FROM userreport "+
"JOIN report "+
"ON userreport.category = report.category");
function procedure1() {
return WL.Server.invokeSQLStatement({
preparedStatement : procedure1Statement,
});
}
function procedure2(param) {
return WL.Server.invokeSQLStoredProcedure({
procedure : "storedProcedure2",
parameters : [param]
});
}
我希望代码一切正常,但我无法在应用程序屏幕上显示结果,浏览器的开发人员工具控制台中会显示以下错误。
"Initialization option 'connectOnStartup' is deprecated. Use WL.Client.connect() to connect to the IBM MobileFirst Platform Server." worklight.js:5059
no element found loguploader:1
no element found loguploader:1
请告诉我,我哪里出错?
答案 0 :(得分:1)
您需要将HTML中的UL
替换为表格,然后您需要附加LI
和{{TD
s,而不是附加TR
s。 1}} s,取决于你的桌子设计。
我建议先创建一个带有虚拟数据的静态表 然后用来自JS的数据替换虚拟数据。