无法正确调用保存对象

Cannot call save object properly

本文关键字:保存 对象 调用      更新时间:2023-09-26

我有一个不知道如何解决的问题。我有一个表单,我用它来显示数据,也编辑数据。

<!-- 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>&nbsp;
<!-- 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>

当我点击按钮时,表单没有提交,Java方法savedata没有被调用。

我认为jQuery选择器中缺少引号:

jQuery(button).closest("form").find("[id$='editdata']").click();