You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by HHB <hu...@yahoo.ca> on 2009/04/30 11:29:46 UTC

How to remove a row from DataTable?

Hey,
I employed AjaxFallbackDefaultDataTable to list contacts.
The last column contains a delete link that I created it this way:
********************
final List<IColumn> columns = new ArrayList<IColumn>();
columns.add(new AbstractColumn(new Model("Delete")) {
        public void populateItem(Item cellItem, 
           String componentId, IModel rowModel) {
                Contact contact = ((Contact) 
                   rowModel.getObject());
                cellItem.add(new 
                   DeleteContactPanel(componentId, contact));
            }
        });
********************
public DeleteContactPanel(String id, 
       final Contact contact) {
   super(id);
   setOutputMarkupId(true);
   final Form form = new Form("form");
   form.add(new AjaxSubmitLink("delete") {
       @Override
        protected void onSubmit(AjaxRequestTarget target, 
            Form form) {
            service.deleteContact(contact);
            System.out.println("OK Deleted");
        }
    });
    add(form);
}
********************
When deleting the contact from the database, I want to 
remove its row also from AjaxFallbackDefaultDataTable 
and display a message.
But I'm not sure how to accomplish this?
I mean how to communicate between DeleteActionPanel 
and the DataTable?
Would you please help me?
Thanks for help and time.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to remove a row from DataTable?

Posted by "Mathias P.W Nilsson" <ma...@snyltarna.se>.
Actually is the wicket coders that uses this style in amost every component. 
-- 
View this message in context: http://www.nabble.com/How-to-remove-a-row-from-DataTable--tp23312849p23315231.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to remove a row from DataTable?

Posted by HHB <hu...@yahoo.ca>.
Thanks, your suggestion works like a charm.
I like the technique of using abstract method, you have a Swing development
background, right?
Thanks again.


Mathias P.W Nilsson wrote:
> 
> I don't know if you can remove one row and just update the row as you can
> with TreeTable but maybe some here could guide you.
> 
> If it is good enough to update the whole table then maybe somthing like
> this. this is typed from my head so there may be errors.
> 
> public abstract DeleteContactPanel extends Panel{
>   public DeleteContactPanel(String id, final Contact contact) { 		
>     super(id); 
>     setOutputMarkupId(true); 
>     final Form form = new Form("form"); 
>     form.add(new AjaxSubmitLink("delete") { 
>       @Override 
>       protected void onSubmit(AjaxRequestTarget target,  Form form) { 
>         service.deleteContact(contact); 
>         onDelete( target );
> 	System.out.println("OK Deleted"); 
>       } 
>     }); 
>     add(form); 
>   } 
>   public abstract void onDelete( AjaxrequestTarget target );
> }
> 
> 
> final List<IColumn> columns = new ArrayList<IColumn>();
> columns.add(new AbstractColumn(new Model("Delete")) {
>   public void populateItem(Item cellItem, String componentId, IModel
> rowModel) {
>     Contact contact = ((Contact) rowModel.getObject());
>     cellItem.add(new  DeleteContactPanel(componentId, contact){
>       public void onDelete( AjaxRequestTarget target ){
>         // Add table here and show flashmessage
>         info( "Row deleted" );
>         target.addComponent( feedback );
>         target.addComponent( datatable );
>       }
>     });
>   }
> });
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-remove-a-row-from-DataTable--tp23312849p23314945.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to remove a row from DataTable?

Posted by "Mathias P.W Nilsson" <ma...@snyltarna.se>.
I don't know if you can remove one row and just update the row as you can
with TreeTable but maybe some here could guide you.

If it is good enough to update the whole table then maybe somthing like
this. this is typed from my head so there may be errors.

public abstract DeleteContactPanel extends Panel{
  public DeleteContactPanel(String id, final Contact contact) { 		
    super(id); 
    setOutputMarkupId(true); 
    final Form form = new Form("form"); 
    form.add(new AjaxSubmitLink("delete") { 
      @Override 
      protected void onSubmit(AjaxRequestTarget target,  Form form) { 
        service.deleteContact(contact); 
        onDelete( target );
	System.out.println("OK Deleted"); 
      } 
    }); 
    add(form); 
  } 
  public abstract void onDelete( AjaxrequestTarget target );
}


final List<IColumn> columns = new ArrayList<IColumn>();
columns.add(new AbstractColumn(new Model("Delete")) {
  public void populateItem(Item cellItem, String componentId, IModel
rowModel) {
    Contact contact = ((Contact) rowModel.getObject());
    cellItem.add(new  DeleteContactPanel(componentId, contact){
      public void onDelete( AjaxRequestTarget target ){
        // Add table here and show flashmessage
        info( "Row deleted" );
        target.addComponent( feedback );
        target.addComponent( datatable );
      }
    });
  }
});


-- 
View this message in context: http://www.nabble.com/How-to-remove-a-row-from-DataTable--tp23312849p23313786.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org