You are viewing a plain text version of this content. The canonical link for it is here.
Posted to adffaces-user@incubator.apache.org by Henk Vanhoe <He...@kava.be> on 2007/02/13 10:05:31 UTC

Trinidad table - remove a row

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>


Re: Trinidad table - remove a row

Posted by Simon Lessard <si...@gmail.com>.
Hello,

Yes there's a way to force the component being re-rendered. Try the
following (assuming ev is the action event):

RequestContext.getCurrentInstance().addPartialTarget(ev.getComponent());


Regards,

~ Simon

On 2/13/07, Henk Vanhoe <He...@kava.be> wrote:
>
> Thank you for your answer!
>
> I have done some more tests and I noticed that when I push the
> "delete"-button the correct "contact" is removed from the model (the
> "smallTable"-list), but these changes are not correctly translated in
> the HTML-page... But when I replace my actionListener by an action
> method (as you do in your code), the changes are correctly displayed (as
> if with an actionlistener the view were not synchronized with the model??)
> Unfortunately with an actionListener it is impossible to use partial
> page rendering...
>
> Is there a way to force the view to be redisplayed with the correct data
> without losing the possibility to use partial page rendering?
>
> Regards,
> Henk
>
> Matthias Wessendorf wrote:
>
> > What I do is:
> >
> > <tr:column>
> >  <f:facet name="header">
> >    <tr:outputText value="-Delete-"/>
> >  </f:facet>
> >  <tr:commandLink id="delete" text="Delete" action="#{all.deleteUser}">
> >    <tr:setActionListener from="#{user}" to="#{all.toDelete}"/>
> >  </tr:commandLink>
> > </tr:column>
> >
> >
> > in the #{all} bean:
> > private User toDelete = null; (+set/get)
> >
> > and
> > public String deleteUser()
> > {
> >  this.getUserService().removeUser(toDelete);
> >  return ("all");
> > }
> >
> > the user service here is injected w/ spring.
> >
> > The demo is available here:
> >
> > http://code.google.com/p/facesgoodies/
> >
> >
> >
> >
> > On 2/13/07, Henk Vanhoe <He...@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>
> >>
> >>
> >
> >
>
>

Re: Trinidad table - remove a row

Posted by Adam Winer <aw...@gmail.com>.
See my earlier reply...  actionListener vs. action
isn't the deal (BTW, partialTriggers works just fine with
"action" - just return null from the action.)   immediate
vs. non-immediate is what matters, and inputTexts
in a table.

The best solution is using a non-default implementation
of CollectionModel, so row add and remove are handled
correctly.

-- Adam


On 2/13/07, Henk Vanhoe <He...@kava.be> wrote:
> Thank you all for your suggestions...
>
> Finally I think (hope) I found the reason of the behaviour I am seeing.
> Apparently when a row is removed with an actionlistener the
> corresponding "submitted values" are not removed. As a consequence when
> I remove the first row of a table, the submitted values of the second
> row move to the first row, and are displayed when the page is shown
> again. Therefore this problem probably only occurs when the data of the
> table are displayed in inputtext-fields, not in outputtext-fields and
> when immediate="true". This doesn't happen when I use an action method
> either. Is this behaviour normal or is this a bug?
>
> I suppose I can fix this by "manually" setting the submitted values to
> null in my actionListener (but I hope this won't have any other
> consequences).
>
> Kind regards,
> Henk
>
> Matthias Wessendorf wrote:
>
> > Henk,
> >
> > the mentioned example uses that, when the update dialog returns.
> > I'll add some more goodies soon, but it already lot's of ;)
> >
> > -M
> >
> > On 2/13/07, Simon Lessard <si...@gmail.com> wrote:
> >
> >> Oh, sorry, but it's still possible!!! With a bit more work though.
> >>
> >> In the page:
> >>
> >> <tr:table binding="#{myBean.table}" ...>
> >>   ...
> >> </tr:table>
> >>
> >> In the bean:
> >>
> >> private UIComponent table;
> >>
> >> public UIComponent getTable()
> >> {
> >>   return table;
> >> }
> >>
> >> public void setTable(UIComponent table)
> >> {
> >>   this.table = table;
> >> }
> >>
> >> public String myAction()
> >> {
> >>   RequestContext.getCurrentInstance().addPartialTarget(table);
> >>   // ...
> >> }
> >>
> >> On 2/13/07, Henk Vanhoe <He...@kava.be> wrote:
> >> >
> >> > Henk Vanhoe wrote:
> >> >
> >> > > Thank you for your answer!
> >> > >
> >> > > I have done some more tests and I noticed that when I push the
> >> > > "delete"-button the correct "contact" is removed from the model (the
> >> > > "smallTable"-list), but these changes are not correctly
> >> translated in
> >> > > the HTML-page... But when I replace my actionListener by an action
> >> > > method (as you do in your code), the changes are correctly displayed
> >> > > (as if with an actionlistener the view were not synchronized with
> >> the
> >> > > model??)
> >> > > Unfortunately with an actionListener it is impossible to use partial
> >> > > page rendering...
> >> >
> >> > I meant : Unfortunately with an *** action method *** it is impossible
> >> > to use partial page rendering...
> >> >
> >> > >
> >> > > Is there a way to force the view to be redisplayed with the correct
> >> > > data without losing the possibility to use partial page rendering?
> >> > >
> >> > > Regards,
> >> > > Henk
> >> > >
> >> > > Matthias Wessendorf wrote:
> >> > >
> >> > >> What I do is:
> >> > >>
> >> > >> <tr:column>
> >> > >>  <f:facet name="header">
> >> > >>    <tr:outputText value="-Delete-"/>
> >> > >>  </f:facet>
> >> > >>  <tr:commandLink id="delete" text="Delete"
> >> action="#{all.deleteUser}">
> >> > >>    <tr:setActionListener from="#{user}" to="#{all.toDelete}"/>
> >> > >>  </tr:commandLink>
> >> > >> </tr:column>
> >> > >>
> >> > >>
> >> > >> in the #{all} bean:
> >> > >> private User toDelete = null; (+set/get)
> >> > >>
> >> > >> and
> >> > >> public String deleteUser()
> >> > >> {
> >> > >>  this.getUserService().removeUser(toDelete);
> >> > >>  return ("all");
> >> > >> }
> >> > >>
> >> > >> the user service here is injected w/ spring.
> >> > >>
> >> > >> The demo is available here:
> >> > >>
> >> > >> http://code.google.com/p/facesgoodies/
> >> > >>
> >> > >>
> >> > >>
> >> > >>
> >> > >> On 2/13/07, Henk Vanhoe <He...@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>
> >> > >>>
> >> > >>>
> >> > >>
> >> > >>
> >> > >
> >> >
> >> >
> >>
> >
> >
>
>

Re: Trinidad table - remove a row

Posted by Henk Vanhoe <He...@kava.be>.
Thank you all for your suggestions...

Finally I think (hope) I found the reason of the behaviour I am seeing. 
Apparently when a row is removed with an actionlistener the 
corresponding "submitted values" are not removed. As a consequence when 
I remove the first row of a table, the submitted values of the second 
row move to the first row, and are displayed when the page is shown 
again. Therefore this problem probably only occurs when the data of the 
table are displayed in inputtext-fields, not in outputtext-fields and 
when immediate="true". This doesn't happen when I use an action method 
either. Is this behaviour normal or is this a bug?

I suppose I can fix this by "manually" setting the submitted values to 
null in my actionListener (but I hope this won't have any other 
consequences).

Kind regards,
Henk

Matthias Wessendorf wrote:

> Henk,
>
> the mentioned example uses that, when the update dialog returns.
> I'll add some more goodies soon, but it already lot's of ;)
>
> -M
>
> On 2/13/07, Simon Lessard <si...@gmail.com> wrote:
>
>> Oh, sorry, but it's still possible!!! With a bit more work though.
>>
>> In the page:
>>
>> <tr:table binding="#{myBean.table}" ...>
>>   ...
>> </tr:table>
>>
>> In the bean:
>>
>> private UIComponent table;
>>
>> public UIComponent getTable()
>> {
>>   return table;
>> }
>>
>> public void setTable(UIComponent table)
>> {
>>   this.table = table;
>> }
>>
>> public String myAction()
>> {
>>   RequestContext.getCurrentInstance().addPartialTarget(table);
>>   // ...
>> }
>>
>> On 2/13/07, Henk Vanhoe <He...@kava.be> wrote:
>> >
>> > Henk Vanhoe wrote:
>> >
>> > > Thank you for your answer!
>> > >
>> > > I have done some more tests and I noticed that when I push the
>> > > "delete"-button the correct "contact" is removed from the model (the
>> > > "smallTable"-list), but these changes are not correctly 
>> translated in
>> > > the HTML-page... But when I replace my actionListener by an action
>> > > method (as you do in your code), the changes are correctly displayed
>> > > (as if with an actionlistener the view were not synchronized with 
>> the
>> > > model??)
>> > > Unfortunately with an actionListener it is impossible to use partial
>> > > page rendering...
>> >
>> > I meant : Unfortunately with an *** action method *** it is impossible
>> > to use partial page rendering...
>> >
>> > >
>> > > Is there a way to force the view to be redisplayed with the correct
>> > > data without losing the possibility to use partial page rendering?
>> > >
>> > > Regards,
>> > > Henk
>> > >
>> > > Matthias Wessendorf wrote:
>> > >
>> > >> What I do is:
>> > >>
>> > >> <tr:column>
>> > >>  <f:facet name="header">
>> > >>    <tr:outputText value="-Delete-"/>
>> > >>  </f:facet>
>> > >>  <tr:commandLink id="delete" text="Delete" 
>> action="#{all.deleteUser}">
>> > >>    <tr:setActionListener from="#{user}" to="#{all.toDelete}"/>
>> > >>  </tr:commandLink>
>> > >> </tr:column>
>> > >>
>> > >>
>> > >> in the #{all} bean:
>> > >> private User toDelete = null; (+set/get)
>> > >>
>> > >> and
>> > >> public String deleteUser()
>> > >> {
>> > >>  this.getUserService().removeUser(toDelete);
>> > >>  return ("all");
>> > >> }
>> > >>
>> > >> the user service here is injected w/ spring.
>> > >>
>> > >> The demo is available here:
>> > >>
>> > >> http://code.google.com/p/facesgoodies/
>> > >>
>> > >>
>> > >>
>> > >>
>> > >> On 2/13/07, Henk Vanhoe <He...@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>
>> > >>>
>> > >>>
>> > >>
>> > >>
>> > >
>> >
>> >
>>
>
>


Re: Trinidad table - remove a row

Posted by Matthias Wessendorf <ma...@apache.org>.
Henk,

the mentioned example uses that, when the update dialog returns.
I'll add some more goodies soon, but it already lot's of ;)

-M

On 2/13/07, Simon Lessard <si...@gmail.com> wrote:
> Oh, sorry, but it's still possible!!! With a bit more work though.
>
> In the page:
>
> <tr:table binding="#{myBean.table}" ...>
>   ...
> </tr:table>
>
> In the bean:
>
> private UIComponent table;
>
> public UIComponent getTable()
> {
>   return table;
> }
>
> public void setTable(UIComponent table)
> {
>   this.table = table;
> }
>
> public String myAction()
> {
>   RequestContext.getCurrentInstance().addPartialTarget(table);
>   // ...
> }
>
> On 2/13/07, Henk Vanhoe <He...@kava.be> wrote:
> >
> > Henk Vanhoe wrote:
> >
> > > Thank you for your answer!
> > >
> > > I have done some more tests and I noticed that when I push the
> > > "delete"-button the correct "contact" is removed from the model (the
> > > "smallTable"-list), but these changes are not correctly translated in
> > > the HTML-page... But when I replace my actionListener by an action
> > > method (as you do in your code), the changes are correctly displayed
> > > (as if with an actionlistener the view were not synchronized with the
> > > model??)
> > > Unfortunately with an actionListener it is impossible to use partial
> > > page rendering...
> >
> > I meant : Unfortunately with an *** action method *** it is impossible
> > to use partial page rendering...
> >
> > >
> > > Is there a way to force the view to be redisplayed with the correct
> > > data without losing the possibility to use partial page rendering?
> > >
> > > Regards,
> > > Henk
> > >
> > > Matthias Wessendorf wrote:
> > >
> > >> What I do is:
> > >>
> > >> <tr:column>
> > >>  <f:facet name="header">
> > >>    <tr:outputText value="-Delete-"/>
> > >>  </f:facet>
> > >>  <tr:commandLink id="delete" text="Delete" action="#{all.deleteUser}">
> > >>    <tr:setActionListener from="#{user}" to="#{all.toDelete}"/>
> > >>  </tr:commandLink>
> > >> </tr:column>
> > >>
> > >>
> > >> in the #{all} bean:
> > >> private User toDelete = null; (+set/get)
> > >>
> > >> and
> > >> public String deleteUser()
> > >> {
> > >>  this.getUserService().removeUser(toDelete);
> > >>  return ("all");
> > >> }
> > >>
> > >> the user service here is injected w/ spring.
> > >>
> > >> The demo is available here:
> > >>
> > >> http://code.google.com/p/facesgoodies/
> > >>
> > >>
> > >>
> > >>
> > >> On 2/13/07, Henk Vanhoe <He...@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>
> > >>>
> > >>>
> > >>
> > >>
> > >
> >
> >
>


-- 
Matthias Wessendorf
http://tinyurl.com/fmywh

further stuff:
blog: http://jroller.com/page/mwessendorf
mail: mwessendorf-at-gmail-dot-com

Re: Trinidad table - remove a row

Posted by Simon Lessard <si...@gmail.com>.
Oh, sorry, but it's still possible!!! With a bit more work though.

In the page:

<tr:table binding="#{myBean.table}" ...>
  ...
</tr:table>

In the bean:

private UIComponent table;

public UIComponent getTable()
{
  return table;
}

public void setTable(UIComponent table)
{
  this.table = table;
}

public String myAction()
{
  RequestContext.getCurrentInstance().addPartialTarget(table);
  // ...
}

On 2/13/07, Henk Vanhoe <He...@kava.be> wrote:
>
> Henk Vanhoe wrote:
>
> > Thank you for your answer!
> >
> > I have done some more tests and I noticed that when I push the
> > "delete"-button the correct "contact" is removed from the model (the
> > "smallTable"-list), but these changes are not correctly translated in
> > the HTML-page... But when I replace my actionListener by an action
> > method (as you do in your code), the changes are correctly displayed
> > (as if with an actionlistener the view were not synchronized with the
> > model??)
> > Unfortunately with an actionListener it is impossible to use partial
> > page rendering...
>
> I meant : Unfortunately with an *** action method *** it is impossible
> to use partial page rendering...
>
> >
> > Is there a way to force the view to be redisplayed with the correct
> > data without losing the possibility to use partial page rendering?
> >
> > Regards,
> > Henk
> >
> > Matthias Wessendorf wrote:
> >
> >> What I do is:
> >>
> >> <tr:column>
> >>  <f:facet name="header">
> >>    <tr:outputText value="-Delete-"/>
> >>  </f:facet>
> >>  <tr:commandLink id="delete" text="Delete" action="#{all.deleteUser}">
> >>    <tr:setActionListener from="#{user}" to="#{all.toDelete}"/>
> >>  </tr:commandLink>
> >> </tr:column>
> >>
> >>
> >> in the #{all} bean:
> >> private User toDelete = null; (+set/get)
> >>
> >> and
> >> public String deleteUser()
> >> {
> >>  this.getUserService().removeUser(toDelete);
> >>  return ("all");
> >> }
> >>
> >> the user service here is injected w/ spring.
> >>
> >> The demo is available here:
> >>
> >> http://code.google.com/p/facesgoodies/
> >>
> >>
> >>
> >>
> >> On 2/13/07, Henk Vanhoe <He...@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>
> >>>
> >>>
> >>
> >>
> >
>
>

Re: Trinidad table - remove a row

Posted by Henk Vanhoe <He...@kava.be>.
Henk Vanhoe wrote:

> Thank you for your answer!
>
> I have done some more tests and I noticed that when I push the 
> "delete"-button the correct "contact" is removed from the model (the 
> "smallTable"-list), but these changes are not correctly translated in 
> the HTML-page... But when I replace my actionListener by an action 
> method (as you do in your code), the changes are correctly displayed 
> (as if with an actionlistener the view were not synchronized with the 
> model??)
> Unfortunately with an actionListener it is impossible to use partial 
> page rendering...

I meant : Unfortunately with an *** action method *** it is impossible 
to use partial page rendering...

>
> Is there a way to force the view to be redisplayed with the correct 
> data without losing the possibility to use partial page rendering?
>
> Regards,
> Henk
>
> Matthias Wessendorf wrote:
>
>> What I do is:
>>
>> <tr:column>
>>  <f:facet name="header">
>>    <tr:outputText value="-Delete-"/>
>>  </f:facet>
>>  <tr:commandLink id="delete" text="Delete" action="#{all.deleteUser}">
>>    <tr:setActionListener from="#{user}" to="#{all.toDelete}"/>
>>  </tr:commandLink>
>> </tr:column>
>>
>>
>> in the #{all} bean:
>> private User toDelete = null; (+set/get)
>>
>> and
>> public String deleteUser()
>> {
>>  this.getUserService().removeUser(toDelete);
>>  return ("all");
>> }
>>
>> the user service here is injected w/ spring.
>>
>> The demo is available here:
>>
>> http://code.google.com/p/facesgoodies/
>>
>>
>>
>>
>> On 2/13/07, Henk Vanhoe <He...@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>
>>>
>>>
>>
>>
>


Re: Trinidad table - remove a row

Posted by Henk Vanhoe <He...@kava.be>.
Thank you for your answer!

I have done some more tests and I noticed that when I push the 
"delete"-button the correct "contact" is removed from the model (the 
"smallTable"-list), but these changes are not correctly translated in 
the HTML-page... But when I replace my actionListener by an action 
method (as you do in your code), the changes are correctly displayed (as 
if with an actionlistener the view were not synchronized with the model??)
Unfortunately with an actionListener it is impossible to use partial 
page rendering...

Is there a way to force the view to be redisplayed with the correct data 
without losing the possibility to use partial page rendering?

Regards,
Henk

Matthias Wessendorf wrote:

> What I do is:
>
> <tr:column>
>  <f:facet name="header">
>    <tr:outputText value="-Delete-"/>
>  </f:facet>
>  <tr:commandLink id="delete" text="Delete" action="#{all.deleteUser}">
>    <tr:setActionListener from="#{user}" to="#{all.toDelete}"/>
>  </tr:commandLink>
> </tr:column>
>
>
> in the #{all} bean:
> private User toDelete = null; (+set/get)
>
> and
> public String deleteUser()
> {
>  this.getUserService().removeUser(toDelete);
>  return ("all");
> }
>
> the user service here is injected w/ spring.
>
> The demo is available here:
>
> http://code.google.com/p/facesgoodies/
>
>
>
>
> On 2/13/07, Henk Vanhoe <He...@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>
>>
>>
>
>


Re: Trinidad table - remove a row

Posted by Matthias Wessendorf <ma...@apache.org>.
What I do is:

<tr:column>
  <f:facet name="header">
    <tr:outputText value="-Delete-"/>
  </f:facet>
  <tr:commandLink id="delete" text="Delete" action="#{all.deleteUser}">
    <tr:setActionListener from="#{user}" to="#{all.toDelete}"/>
  </tr:commandLink>
</tr:column>


in the #{all} bean:
private User toDelete = null; (+set/get)

and
public String deleteUser()
{
  this.getUserService().removeUser(toDelete);
  return ("all");
}

the user service here is injected w/ spring.

The demo is available here:

http://code.google.com/p/facesgoodies/




On 2/13/07, Henk Vanhoe <He...@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>
>
>


-- 
Matthias Wessendorf
http://tinyurl.com/fmywh

further stuff:
blog: http://jroller.com/page/mwessendorf
mail: mwessendorf-at-gmail-dot-com

Re: Trinidad table - remove a row

Posted by Adam Winer <aw...@gmail.com>.
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 <He...@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>
>
>