Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.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
在进行JSF Ajax调用时,变量被设置为null_Ajax_Jsf 2.2 - Fatal编程技术网

在进行JSF Ajax调用时,变量被设置为null

在进行JSF Ajax调用时,变量被设置为null,ajax,jsf-2.2,Ajax,Jsf 2.2,我有一个@viewscopewordcontrollercdibean。它有一个方法addWord(),将变量currentWord添加到列表中。它在没有AJAX的情况下可以正常工作,但是只要我包含f:AJAX,变量currentWord在addWord()方法中总是空的。在ajax与JSF的合作方式上,我缺少了一些东西。这里出了什么问题 <h:form id="saveForm" styleClass="form"> <h:inputText value="#{wor

我有一个
@viewscope
wordcontrollercdibean。它有一个方法
addWord()
,将变量
currentWord
添加到
列表中。它在没有AJAX的情况下可以正常工作,但是只要我包含
f:AJAX
,变量
currentWord
addWord()
方法中总是空的。在ajax与JSF的合作方式上,我缺少了一些东西。这里出了什么问题

<h:form id="saveForm" styleClass="form">
    <h:inputText value="#{wordController.currentWord}" id="words" />
    <h:commandButton action="#{wordController.addWord()}" type="submit" value="+">
        <f:ajax render="wordlist" />
    </h:commandButton>
    <h:panelGroup id="wordlist">
....

....

f:ajax
默认为
execute=“@this”
(在本例中等于
commandButton
),因此不会执行inputText(≈ 提交)。这就是它在动作中为空的原因。加上

<f:ajax execute="@form" render="wordlist" /> 

执行整个表格,或

<f:ajax execute="@this words" render="wordlist" /> 

仅执行inputText和按钮-以防有更多您不希望提交的inputcomponents

在后一种情况下,您需要
@此
,因为没有它,只有
会执行,因此不会执行
命令按钮
,也不会执行操作


更多阅读。

f:ajax
默认为
execute=“@this”
(在本例中等于
commandButton
),因此不会执行inputText(≈ 提交)。这就是它在动作中为空的原因。加上

<f:ajax execute="@form" render="wordlist" /> 

执行整个表格,或

<f:ajax execute="@this words" render="wordlist" /> 

仅执行inputText和按钮-以防有更多您不希望提交的inputcomponents

在后一种情况下,您需要
@此
,因为没有它,只有
会执行,因此不会执行
命令按钮
,也不会执行操作

更多的是阅读