incubator-adffaces-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Winer" <awi...@gmail.com>
Subject Re: Trinidad table - remove a row
Date Tue, 13 Feb 2007 17:23:02 GMT
I suspect that if you switched your column contents to
outputText (as a test), that you'd see the right rows got
deleted.

The problem here is that the table doesn't have any inherent
way to notice that any particular row got removed, and its
internal state - keeping track of temporary values on one
row or another - gets confused, and it starts applying
values to different rows.

h:dataTable and the JSF DataModel API has no way around this,
as rows are only identifed by index - getRowIndex(), setRowIndex().
But Trinidad's CollectionModel does - getRowKey() and setRowKey(),
which default to just being the row index, but can be implemented
otherwise.

You could implement this yourself (not that much work), but
we should have a built-in implementation that handles this.
Just filed:
  http://issues.apache.org/jira/browse/ADFFACES-380

-- Adam


On 2/13/07, Henk Vanhoe <Henk.Vanhoe@kava.be> wrote:
> Hi,
>
> I'm trying to create a (trinidad) table in which it is possible to
> remove a row. Next to each row, a "delete"-button is displayed. However,
> each time I push the delete button, a wrong row is deleted (for
> instance, when I push the delete button next to the first row, the third
> row is removed)! Does anyone have an idea why this may be happening???
>
> Regards,
> Henk
>
> JSF-code:
>
>                 <tr:table var="row" value="#{tableBean.smallTable}"
> rowBandingInterval="1"
>                     binding="#{tableBean.smallTableBinding}">
>                     <tr:column sortProperty="naam" sortable="true">
>                         <f:facet name="header">
>                             <tr:outputText value="Naam" />
>                         </f:facet>
>                         <tr:inputText id="voornaam"    value="#{row.naam}"/>
>                     </tr:column>
>                     <tr:column sortProperty="voornaam" sortable="true">
>                         <f:facet name="header">
>                             <tr:outputText value="Voornaam" />
>                         </f:facet>
>                         <tr:inputText value="#{row.voornaam}" />
>                     </tr:column>
>                     <tr:column sortProperty="leeftijd" sortable="true">
>                         <f:facet name="header">
>                             <tr:outputText value="Leeftijd" />
>                         </f:facet>
>                         <tr:inputText value="#{row.leeftijd}" />
>                     </tr:column>
>                     <tr:column>
>                       <tr:commandLink id="removeContact"
>                         text="Remove"
>                         actionListener="#{tableBean.removeContact}"
>                         immediate="true" />
>                     </tr:column>
>                 </tr:table>
>
> Managed bean:
>
> public class TableBean {
>     private List<Contact> smallTable;
>     private UIXTable smallTableBinding;
>
>     public TableBean() {
>         this.smallTable =  new ArrayList<Contact>();
>
>         Contact c1 = new Contact();
>         c1.setNaam("Vandam");
>         c1.setVoornaam("Alain");
>         c1.setLeeftijd("33");
>         smallTable.add(c1);
>
>         Contact c2 = new Contact();
>         c2.setNaam("Tanghe");
>         c2.setVoornaam("Sammy");
>         c2.setLeeftijd("36");
>         smallTable.add(c2);
>
>         Contact c3 = new Contact();
>         c3.setNaam("Laplasse");
>         c3.setVoornaam("Bucky");
>         c3.setLeeftijd("42");
>         smallTable.add(c3);
>     }
>
>     public void removeContact(ActionEvent event) throws Exception {
>         logger.info("Inside TableBean.removeContact()");
>
>         Contact contact = (Contact) smallTableBinding.getRowData();
>         Collection contacten = (Collection) smallTableBinding.getValue();
>         contacten.remove(contact);
>     }
>
>     //Getters, setters and other methods...
> }
>
> faces-config:
>
>   <managed-bean>
>     <managed-bean-name>tableBean</managed-bean-name>
>     <managed-bean-class>be.kava.jsfdemo.table.TableBean</managed-bean-class>
>     <managed-bean-scope>session</managed-bean-scope>
>   </managed-bean>
>
>

Mime
View raw message