Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/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 rich中的值:在bean中未更新dataTable_Jsf_Jsf 2_Richfaces - Fatal编程技术网

Jsf rich中的值:在bean中未更新dataTable

Jsf rich中的值:在bean中未更新dataTable,jsf,jsf-2,richfaces,Jsf,Jsf 2,Richfaces,这个问题是在迁移到richfaces4.3和JSF2.0时出现的 上下文是:rich:dataTable在其各自的列中采用answerId、answerDefinition等。onchange事件在answerid列上执行,其中添加了新行 <rich:extendedDataTable rowKeyVar="currentRowVar" value="#{DiscQuestMgtController.answerChoiceList}" var="d

这个问题是在迁移到richfaces4.3和JSF2.0时出现的

上下文是:rich:dataTable在其各自的列中采用answerId、answerDefinition等。onchange事件在answerid列上执行,其中添加了新行

<rich:extendedDataTable rowKeyVar="currentRowVar"
        value="#{DiscQuestMgtController.answerChoiceList}"
            var="dataItem" rowClasses="row1, row2" id="ansChoiceList">
                <rich:column width="160" sortable="false">
                   <h:inputText id="answerID"  value="#{dataItem.answerId}"
                            onchange="addNewRowToAnsChoice('DiscQuestMgtForm',#{fn:length(DiscQuestMgtController.answerChoiceList)});" />     
                </rich:column>
                <rich:column sortable="false">
                    <h:inputText id="choiceValue" value="#{dataItem.choiceValue}"/>
                </rich:column>
                <rich:column sortable="false">
                    <h:inputText id="definitionId"  value="#{dataItem.definition}"/>
                </rich:column>
    </rich:extendedDataTable> 
removeMptyChoiceRow()检查是否存在任何现有的空行,并将其删除,以添加新行@abc,列表大小始终是默认值。(页面加载时始终有一行),尽管输入了值,但这一行不会改变。请建议

这是a4j:功能:

<a4j:jsFunction name="addEmptyAnsChoice"
                render="ansChoiceList,addDiscQuest,applyDiscQuest"
                actionListener="#{DiscQuestMgtController.addEmptyRow}"
                oncomplete="focusToNewCell('DiscQuestMgtForm',#{fn:length(DiscQuestMgtController.answerChoiceList)});">
            </a4j:jsFunction>

从JSF 1.2到JSF 2的一个主要变化是引入了属性
render
execute
替换
rerender

  • execute
    部分更新树的标记部分的模型
  • render
    呈现树的标记部分,并通过AJAX发送以替换原始部分
例如,当侦听器更新页面上显示为输入字段的值时,这非常方便

更新:您在更改
应答ID
时调用
addNewRowToAnsChoice
,稍后调用
a4j:jsFunction
addEmptyAnsChoice

在那里,元素
ansChoiceList
addDiscQuest
applyDiscQuest
被重新检索,但是没有为
execute
发送任何内容。因此,您在-well中输入的
answerId
行在服务器端永远不会更新

在下一步中,在actionListener中删除所有空行(这一行也是如此),并在底部添加新的行

在我看来,尝试跳过jsFunction调用,而让相同的东西作为
f:ajax
a4j:ajax
执行。(未测试的)代码可能如下所示

<h:inputText id="answerID"  value="#{dataItem.answerId}"
                        onchange="<yourValidationFunction>">
    <a4j:ajax execute="@this"
            render="ansChoiceList addDiscQuest applyDiscQuest"
            actionListener="#{DiscQuestMgtController.addEmptyRow}"
            oncomplete="focusToNewCell('DiscQuestMgtForm',#{fn:length(DiscQuestMgtController.answerChoiceList)});">
    </a4j:ajax>
</h:inputText>

通过这种方式,您可以将ID与要在服务器端更新的值分开


希望它能起作用并有帮助……

你能包括
{DiscQuestMgtController.answerChoiceList}
的方法定义以及相关bean的作用域吗?所提到的输入字段一经更改就会触发函数
addNewRowToAnsChoice
。这是您的功能之一。为了真正帮助您,请删除xhtml中不重要的部分(例如f:facet name=“header”、style),这样可以更容易地理解您的问题。还提供连接的JavaScript函数和托管bean,例如,
DiscQuestMgtController
@L-Ray我编辑了我的问题。@mzzb bean是会话范围的。请看我编辑的问题。谢谢你。。它确实奏效了。。我添加了执行属性:)@L-RayCool…'nd thnx用于反馈。
<h:inputText id="answerID"  value="#{dataItem.answerId}"
                        onchange="<yourValidationFunction>">
    <a4j:ajax execute="@this"
            render="ansChoiceList addDiscQuest applyDiscQuest"
            actionListener="#{DiscQuestMgtController.addEmptyRow}"
            oncomplete="focusToNewCell('DiscQuestMgtForm',#{fn:length(DiscQuestMgtController.answerChoiceList)});">
    </a4j:ajax>
</h:inputText>