Note that there are some explanatory texts on larger screens.

plurals
  1. POValues in rich:dataTable not getting updated in the bean
    text
    copied!<p>This problem is when we are migrating to richfaces4.3 and JSF2.0. </p> <p>The context is: A rich:dataTable takes answerId, answerDefinition etc in their respective columns. An onchange event is executed on the answerid column, wherein a new row is added. </p> <pre><code>&lt;rich:extendedDataTable rowKeyVar="currentRowVar" value="#{DiscQuestMgtController.answerChoiceList}" var="dataItem" rowClasses="row1, row2" id="ansChoiceList"&gt; &lt;rich:column width="160" sortable="false"&gt; &lt;h:inputText id="answerID" value="#{dataItem.answerId}" onchange="addNewRowToAnsChoice('DiscQuestMgtForm',#{fn:length(DiscQuestMgtController.answerChoiceList)});" /&gt; &lt;/rich:column&gt; &lt;rich:column sortable="false"&gt; &lt;h:inputText id="choiceValue" value="#{dataItem.choiceValue}"/&gt; &lt;/rich:column&gt; &lt;rich:column sortable="false"&gt; &lt;h:inputText id="definitionId" value="#{dataItem.definition}"/&gt; &lt;/rich:column&gt; &lt;/rich:extendedDataTable&gt; </code></pre> <p>When retrieving the values into the dataTable, the working is fine. But when I enter the value into answerId(the first cell) and shift focus, the existing row is totally eliminated creating a new row. </p> <p><strong>addNewRowToAnsChoice</strong> , JS method, does few validations of the entered values and in turn calls a a4j function .. <strong>addEmptyAnsChoice</strong> .. The below is the code, that adds a new row, in the backing bean. </p> <p>//AddNewRow</p> <pre><code>public void addEmptyRow( ActionEvent ae ) { removeEmptyChoiceRow(); String logStr = " DiscQuestMgtController:addEmptyRow()&gt;&gt;&gt;"; logger.debug( logStr + " Entered" ); AnswerChoiceBean bean = new AnswerChoiceBean(); bean.setQuestionId( discQuestBean.getQuestionId() ); logger.debug( logStr + "Choice list size: answerChoiceList size--&gt;",answerChoiceList.size() ); //@abc if ( answerChoiceList.size() == 1 ) answerChoiceList.get( 0 ).setQuestionId( discQuestBean.getQuestionId() ); if ( !answerChoiceList.contains( bean ) ) answerChoiceList.add( bean ); logger.debug( logStr + " Returned" ); } </code></pre> <p>removeEmptyChoiceRow() checks if there are any existing empty rows and deletes them, to add a new row. @abc, the list size is always the default one. (there is always one row on page load), which is just not changing though the values are entered. Pls suggest!!</p> <p>This is the a4j:function:</p> <pre><code>&lt;a4j:jsFunction name="addEmptyAnsChoice" render="ansChoiceList,addDiscQuest,applyDiscQuest" actionListener="#{DiscQuestMgtController.addEmptyRow}" oncomplete="focusToNewCell('DiscQuestMgtForm',#{fn:length(DiscQuestMgtController.answerChoiceList)});"&gt; &lt;/a4j:jsFunction&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload