简体   繁体   English

无法正确调用保存对象

[英]Cannot call save object properly

I have a problem which I don't know how to solve. 我有一个我不知道如何解决的问题。 I have a form which I use to display data and also to edit data. 我有一个用来显示数据和编辑数据的表格。

<!-- 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>

I use this JavaScript in order to confirm edit of data: 我使用此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;
            }
        }
    });
}

But after checking server longs data the Java method saveData is never called by the JavaScript. 但是在检查了服务器请求数据后,JavaScript从未调用过Java方法saveData I'm missing something which I cannot find. 我缺少了一些找不到的东西。 Can you help me to find my mistake, please. 请你能帮我发现我的错误。

EDIT:

The problem is here: 问题在这里:

<!-- 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>

When I click the button the form is not submitted and the the Java method savedata is not called. 当我单击按钮时,不提交表单,并且不调用Java方法savedata

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM