我有一个问题,我不知道如何解决。我有一个用于显示数据和编辑数据的表单。
<!-- New Network button -->
<h:button style="position:absolute; bottom:25px; right:265px;" styleClass="buttonImage" value="New Network" outcome="/Network/NewNetwork.xhtml" rendered="#{not bean.editable}"/>
<!-- Edit button -->
<h:commandButton style="position:absolute; bottom:25px; right:150px;" styleClass="buttonImage" onclick="this.disabled = true;" value=" Edit Network " rendered="#{not bean.editable}" action="#{bean.editNetwork(true)}" >
<f:ajax render="@form" execute="@form"></f:ajax>
</h:commandButton>
<!-- Save Changes button -->
<h:commandButton style="position:absolute; bottom:25px; right:150px;" rendered="#{bean.editable}" styleClass="buttonImage" value=" Save Changes " onclick="editdialog(this, 'Do you want to save the changes?');
return false;" />
<!-- Hidden Edit button -->
<h:commandButton id="editdata" value="HiddenDelete" action="#{bean.saveData}" style="display:none">
<f:ajax render="@form" execute="@form"></f:ajax>
</h:commandButton>
<!-- Cancel button -->
<h:commandButton style="position:absolute; bottom:25px; right:65px;" styleClass="buttonImage" value=" Cancel " rendered="#{bean.editable}" action="#{bean.initDBData}" >
<f:ajax render="@form"></f:ajax>
</h:commandButton>
我使用这个 JavaScript 来确认数据的编辑:
// Question Dialog for edit panel
function editdialog(button, a) {
jQuery("<div />", {
text: a
}).dialog({
width: 600,
buttons: {
"Ok": function() {
jQuery(button).closest("form").find("[id$=editdata]").click();
//$("form\\:deleterow").click();
jQuery(this).dialog("close");
button.value = "Processing...";
button.disabled = true;
},
"Cancel": function(event) {
jQuery(this).dialog("close");
event.preventDefault();
button.value = "Save Changes";
button.disabled = false;
}
}
});
}
但是在检查服务器长数据后,Java 方法saveData
永远不会被 JavaScript 调用。我错过了一些我找不到的东西。请你帮我找出我的错误。
EDIT:
问题在这里:
<!-- Hidden Edit button -->
<h:commandButton id="editdata" value="HiddenDelete" style="position:absolute; bottom:25px; right:650px;" action="#{bean.saveData}" rendered="#{bean.editable}">
<f:ajax render="@form" execute="@form"></f:ajax>
</h:commandButton>
当我单击按钮时,不会提交表单,savedata
也不会调用 Java 方法。