Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/459.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 无法正确调用保存对象_Javascript_Jsf_Jsf 2 - Fatal编程技术网

Javascript 无法正确调用保存对象

Javascript 无法正确调用保存对象,javascript,jsf,jsf-2,Javascript,Jsf,Jsf 2,我有一个我不知道如何解决的问题。我有一个用于显示数据和编辑数据的表单 <!-- 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}"/&g

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

<!-- 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>
问题在于:

<!-- 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();

您在Firebug中跟踪JavaScript执行了吗?是的,有任何输出。好的,据我所知,如果您手动单击editdata按钮,则不会调用save方法,对吗?那么
bean.saveData
看起来是什么样子呢?是的,由于某种原因,这种情况没有发生-Java方法工作不正常。您能从bean中提供一些代码吗?提交表单时,您的
可编辑
属性必须为
true
。也许您使用的是
@RequestScoped
,而
可编辑的
在每个请求中都变为false。好的,但是您是否检查过选择器是否确实找到了按钮?
<!-- 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>
jQuery(button).closest("form").find("[id$='editdata']").click();