Igor Vaynberg <igor.vaynberg <at> gmail.com> writes:

> 
> 
> it would help if we knew what the exception and stacktrace was :)-Igor
> 
> On 4/13/06, Aditya Patel <
> email_to_aditya <at> yahoo.com> wrote:
> I am using datatable view with pagination and sorting to display a list. I am
trying to add a checkbox to the datatable but I keep getting Runtime exception.
Below is my code and I would greatly appreciate if someone can point out the
problem:
> Event.html<form wicket:id="form">        <table>        <tr>            <table
class="dataview" cellspacing="0" wicket:id="table">[table]</table>
>         </tr>        </table>Event.java    public EventIndexPage() {       
add(new HeaderPanel("headerPanel"));                IModel formModel = new
CompoundPropertyModel(new EventDetachableModel(new
>  Event()));        FeedbackPanel feedback = new FeedbackPanel("feedback");   
            add(new NewListForm(feedback, formModel));        add(feedback);   
    add(new EventNavigationBorder("eventNavigationBorder"));
>         add(new EventNavigationPanel("eventNavigationPanel"));    }       
private class NewListForm extends Form {        public NewListForm(IFeedback
feedback, IModel model) {            super("form", model);
>             final List columns = new ArrayList();                //
AbstractColumn implements
>  IColumn            columns.add(new AbstractColumn(new Model("Actions"))   
        {                public void populateItem(Item cellItem, String
componentId, IModel model)                {
>                     cellItem.add(new ActionPanel(componentId, model,
cellItem));                }            });            columns.add(new
PropertyColumn(new Model("Id"), "eventId", "eventId"));
>             columns.add(new PropertyColumn(new Model("Event Description"),
>  "description", "description"));            columns.add(new PropertyColumn(new
Model("Start Date"), "startDate", "startDate"));            columns.add(new
PropertyColumn(new Model("End Date"), "endDate"));
>                         add(new DefaultDataTable("table", columns, new
EventSortableDataProvider(), 8));                        });        }    }   
    class ActionPanel extends Panel
>     {        public ActionPanel(String id, final IModel model, final Item
item)        {   
>          super(id, model);            add(new CheckBox("checkbox",
item.getModel()));        }    }}Event$ActionPanel.html<wicket:panel><td><input
type="checkbox" wicked:id="checkbox" /></td>
> </wicket:panel>Thanks
> 
> __________________________________________________Do You Yahoo!?Tired of spam?
 Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 
> 
> 
> 
> 


I modifed the code and I can display the checkbox. I have a remove button 
that will remove all the checked events. How can I get the checked events from
the dataTable object?

Event.java

                public Event() {
                        FeedbackPanel feedback = new FeedbackPanel("feedback");
                        add(new NewListForm(feedback));
                        add(feedback);
                }
        
        private class NewListForm extends Form {
                public NewListForm(IFeedback feedback) {
                        super("form");
                        final List columns = new ArrayList();

                        columns.add(new PropertyColumn(new Model("Id"), 
"eventId", "eventId"));
                        columns.add(new PropertyColumn(new Model("Event 
Description"), "description",
"description"));
                        columns.add(new PropertyColumn(new Model("Start Date"), 
"startDate",
"startDate"));
                        columns.add(new PropertyColumn(new Model("End Date"), 
"endDate"));
                        columns.add(new AbstractColumn(new Model("Selected"))
                                        {
                                                public void populateItem(Item 
cellItem, String componentId, IModel model)
                                                {
                                                        cellItem.add(new 
ActionPanel(componentId, model, cellItem));
                                                }
                                        });

                        EventsPage.this.table = new DefaultDataTable("table", 
columns, new
EventSortableDataProvider(), 8);
                        add(EventsPage.this.table);
                        
                        add(new Button("removeEvent") {
                                @Override
                                public void onSubmit() {
                                        //How will I get the selected rows?
                                        setResponsePage(new EventsPage("Removed 
the Selected Events"));
                                }
                        });
                }
        }

        class ActionPanel extends Panel
        {
                public ActionPanel(String id, final IModel model, final Item 
item)
                {
                        super(id, model);
                        add(new CheckBox("checked", new AbstractCheckBoxModel() 
{
                                @Override
                                public void setSelected(Component component, 
boolean sel) {
                                        ((EventDetachableModel) 
model).setChecked(sel);
                                }

                                @Override
                                public boolean isSelected(Component component) {
                                        return ((EventDetachableModel) 
model).isChecked();
                                }
                        }));
                }
        }
}





-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to