我需要一些关于来自javascript的js
函数调用的帮助。
我有一个servlet,用于检查协议号是否为null
。
如果协议编号不是null
,那么它将在jsp中显示一个消息框。
Servlet代码是 -
String agrno = request.getParameter("agrno");
System.out.println("agrno in checkcash =" + agrno);
sql = "select agrno from ColdStorage.RecieptMaster where agrno = ?";
prest = (PreparedStatement) conn.prepareStatement(sql);
prest.setString(1, agrno);
String agrid = "";
rs = prest.executeQuery();
while(rs.next())
{
agrid = rs.getString("agrno");
System.out.println("agrid = "+agrid);
}
if(agrid != null)
{
// javascript call should be here.
}
和javascript代码是:
Ext.widget('button', {
renderTo: Ext.getBody()
, text: 'Show Message'
, handler: function () {
Ext.Msg.show({
//title: '',
msg: 'Cash Receipt for specified Agreement number already exist, do you want to regenerate it? ',
buttonText: { yes: "YES", no: "NO"},
buttons: Ext.MessageBox.YESNO
});
}
});
答案 0 :(得分:0)
您可以将agrid
值呈现为HTML代码(到hidden
输入或某个标记的data-
属性),然后在页面加载上运行脚本来检查该参数并相应地显示消息。例如:
HTML / JSP:
<input id="agrid" type="hidden" value="${agrid}">
JavaScript(jQuery):
$(document).ready(function() {
var argid = $('#agrid').val(); //
if (!agrid) {
// Show the message box
}
});