jQuery,JSF和a4j:commandLink [英] JQuery, JSF and a4j:commandLink
本文介绍了jQuery,JSF和a4j:commandLink的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在JSF中使用jQuery对话框和Ajax提交时遇到问题. 我有以下用于显示对话框窗口的代码:
I have a problem with using jQuery Dialog and Ajax submit in JSF. I have the following code for displaying Dialog windows:
<script type="text/javascript">
jQuery(function(){
// Dialog
jQuery('#dialog').dialog({
dialogClass: 'alert',
autoOpen: false,
width: 300,
height: 150,
modal: true,
resizable: false,
overlay: {
backgroundColor: '#000',
opacity: 0.5
},
buttons: {
"Ok": function() {
jQuery(this).dialog("close");
return true;
},
"Cancel": function() {
jQuery(this).dialog("close");
return false;
}
}
});
// Dialog Link
jQuery('#dialog_link').click(function(){
jQuery('#dialog').dialog('open');
return false;
})
.hover(
function() { jQuery(this).addClass('ui-hover-state'); },
function() { jQuery(this).removeClass('ui-hover-state'); }
);
});
</script>
It works as it should - it displays box when link is clicked.
Now, I have something like this, for deleting something:
<a4j:commandLink
actionListener="#some.action"
reRender="something"
onclick="if(!jQuery('#dialog').dialog('open')){return false}"
ok, this commandLink is rendered as follows:
<a href="#"
id="some:long:id:j_id338"
name="formName:something:j_id338"
onclick="if(!jQuery('#dialog').dialog('open')){return
false};A4J.AJAX.Submit('something:something');
return false;"
>drop</a>
现在,显示对话框后,A4j.AJAX.Submit(..)为 被执行,无论如何,例如,我可以通过整个 A4J.AJAX.Submit(...)到对话框"并从确定"选项执行? 仅当用户单击确定"时,我才需要执行提交. 谢谢你的帮助 JQ
now, after displaying the dialog box, the A4j.AJAX.Submit(..) is executed, is there anyway, that I can for example, pass the whole A4J.AJAX.Submit(...) to "dialog" and execute it from "ok" option? I simply need to execute submit if and only if user clicks OK. Thank you for help JQ
推荐答案
您可以定义:
<a4j:jsFunction name="okClicked"
actionListener="#{some.action}"
reRender="something" />
并在OK函数中调用它,例如:
And call it in the OK function, like:
"Ok": function() {
jQuery(this).dialog("close");
okClicked();
return true;
}
这篇关于jQuery,JSF和a4j:commandLink的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文