Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do i remove a row from an icefaces datatable?
    primarykey
    data
    text
    <p>I have a simple ice:dataTable which has 2 columns, one an action column the other a string representing a regular expression. The action column has as its header an add action, and for each row a remove action. I dont really care how this works as long as it does. Right now I am attempting to mimic the icefaces composite component editableTable which requires you to select a row at which point the actions get rendered for that row then when you click an action it is applied to the selected row. So in my attempt to make this work, I created simple datatable with an rowSelector that sets my item.selected for the selected row:</p> <pre><code> &lt;ice:dataTable value="#{configuration.selectedTagPositiveRegexes}" var="item"&gt; &lt;ice:column&gt; &lt;ice:rowSelector value="#{item.selected}" /&gt; &lt;f:facet name="header"&gt; &lt;ice:commandLink styleClass="linkBlue" action="#{configuration.tagRegexAdd}"&gt; &lt;ice:outputText value="Add" /&gt; &lt;/ice:commandLink&gt; &lt;/f:facet&gt; &lt;ice:commandLink styleClass="linkBlue" action="#{configuration.tagRegexRemove}" rendered="#{item.selected}"&gt; &lt;ice:outputText value="Remove" /&gt; &lt;/ice:commandLink&gt; &lt;/ice:column&gt; &lt;ice:column&gt; &lt;f:facet name="header"&gt; &lt;ice:outputText value="Regular Expression" /&gt; &lt;/f:facet&gt; &lt;ice:inputText value="#{item.object}" size="100" /&gt; &lt;/ice:column&gt; &lt;/ice:dataTable&gt; </code></pre> <p>Then in my backing bean, I have these 2 methods:</p> <pre><code>public void tagRegexAdd() { log.debug( "add a new regex" ); for ( SelectableRow&lt;String&gt; row : selectedTagPositiveRegexes ) { row.selected = false; } selectedTagPositiveRegexes.add( 0, new SelectableRow&lt;String&gt;( "", true ) ); } public void tagRegexRemove() { log.debug( "remove an existing regex" ); int i = 0; int selectedIndex = -1; for ( SelectableRow&lt;String&gt; row : selectedTagPositiveRegexes ) { if ( row.selected ) { selectedIndex = i; row.selected = false; } i++; } if ( selectedIndex &gt;= 0 ) { selectedTagPositiveRegexes.remove( selectedIndex ); } } </code></pre> <p>What I notice happening as I step through this code is that the getter for selectedTagPositiveRegexes is getting called 3 times when the remove action is clicked, followed by the actual remove method followed by 1 more call to the getter at which point the browser receives a response that does what I want. However, some event must have been queued by something because after returning the response, the getter gets called 3 more times after which the item after that item that was removed gets replaced with the item that was removed. I have no idea what is going on here and must have a serious misunderstanding as to how this is used, but my assumption was that the datatable, being backed by a list of elements should obtain its content from that list. That way if i add or remove to/from the list, the datatable should represent the new state. But I appear to be terribly wrong in that assumption. Any insight whatsoever as to how this is actually working will be greatly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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