【发布时间】:2015-07-25 18:46:14
【问题描述】:
我在表单中有一个 jsf 页面和一个 commandButton。
<h:form>
...
<h:commandButton action="#{mainViewController.showRelatedPayments()}" id="openpay" onclick="openModal();" value="Tst"></h:commandButton>
...
</h:form>
在同一个 jsf 页面我有一个模态 div..
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Modal titles</h4>
</div>
<div class="modal-body">
....
Dynamic content must be here
....
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
我还有一个包含 openModal() 函数的 javascript 文件。
function openModal() {
$('#myModal').modal('show');
}
当我点击按钮时,它会调用 javascript 函数并显示模态 div,但随后页面刷新和打开模态消失..
按钮也调用了我的backing bean方法:
public void showRelatedPayments() {
LOG.info("creating data for page..");
/*...
...
...
*/
}
我要做的是单击按钮调用支持 bean 方法,该方法为模式内容创建数据,而不是刷新整个 jsf 页面..
这可能吗?有人可以帮我吗?
【问题讨论】:
-
你可能应该从谷歌搜索 ajax 和 jsf 开始,我认为有一些组件/标签是为此设计的
标签: javascript jquery twitter-bootstrap jsf